[英]TableLayout, Text-Align to right
once more: me. 再一次:我。
I have a TableLayout (http://imgur.com/XYdcg) for my "SingleItemAdvancedView" how i like to call it ;) The thing is, I want the data [the TextViews which don't have string *Lbl as android:text set] (so NOT the description like : "name:" , "id:" etc.) to be displayed on the right side of the whole display, not like it's now ( they are displayed right next to the left table-column). 我对我的“ SingleItemAdvancedView”有一个TableLayout(http://imgur.com/XYdcg),我喜欢如何称呼它;文本集(所以不喜欢的描述:“名称:”,“ID”等),以显示在整个显示器的右侧,不喜欢它的现在(它们显示旁边的左表列)。 I tried to align the layout to the right side, as well as only the text (with layout_gravity and gravity only).
我试图将布局以及文本(仅具有layout_gravity和gravity)调整到右侧。 everything didn't work.
一切都没有用。 My widths are all set to fill_parent , so I simply don't understand why.
我的宽度都设置为fill_parent,所以我根本不明白为什么。 Help needed!
需要帮助! Thanks!
谢谢!
My XML for the activity looks like this: 我的活动XML如下所示:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableRow>
<TextView android:text="@string/idLbl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView android:text=""
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/itemidv" />
</TableRow>
<TableRow>
<TextView android:text="@string/nameLbl"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView android:text=""
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/namev" />
</TableRow>
<TableRow>
<TextView android:text="@string/amountLbl"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView android:text=""
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/amountv" />
</TableRow>
<TableRow>
<TextView android:text="@string/unitLbl"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView android:text=""
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/unitv" />
</TableRow>
<TableRow>
<TextView android:text="@string/ppuLbl"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView android:text=""
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/ppuv" />
</TableRow>
<TableRow>
<TextView android:text="@string/totalLbl"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView android:text=""
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/totalv" />
</TableRow>
<TableRow>
<TextView android:text="@string/commentLbl"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView android:text=""
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/commentv" />
</TableRow>
<TableRow>
<TextView android:text="@string/enterqrLbl"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView android:text=""
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/qrcodev" />
</TableRow>
<Button android:text="@string/delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/deleteItemBtn"
android:layout_marginTop="20dp"
android:onClick="btnListener" />
</TableLayout>
You could add android:stretchColumns="0" to TableLayout. 您可以将android:stretchColumns =“ 0”添加到TableLayout。 So you would have something like this:
所以你会有这样的事情:
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="0">
If you want both columns to stretch equally you could use '*' instead of '0'. 如果您希望两列均等地伸展,则可以使用“ *”代替“ 0”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.