我有这个表格布局,前两行有两行,第三行(CustomerAddress)有一行,我想右对齐并占用所有空间。我如何才能做到这一点。我试过gravity = right,但没有成功。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="*" >
<TableRow>
<TextView
style="@style/CustomerLabelTextView"
android:gravity="right"
android:text="@string/customerCode" />
<TextView
style="@style/CustomerLabelTextView"
android:gravity="right"
android:text="@string/customerName" />
</TableRow>
<TableRow>
<TextView
android:id="@+id/customerCode"
style="@style/CustomerTextView"
android:gravity="right" />
<TextView
android:id="@+id/customerName"
style="@style/CustomerTextView"
android:gravity="right" />
</TableRow>
<TableRow>
<TextView
style="@style/CustomerLabelTextView"
android:gravity="right"
android:text="@string/customerAddress" />
</TableRow>
<TableRow>
<TextView
android:id="@+id/customerAddress"
style="@style/CustomerTextView"
android:gravity="right" />
</TableRow>
<TableRow>
<TextView
style="@style/CustomerLabelTextView"
android:gravity="right"
android:text="@string/OrganizationName" />
<TextView
style="@style/CustomerLabelTextView"
android:gravity="right"
android:text="@string/POBox" />
</TableRow>
<TableRow>
<TextView
style="@style/CustomerLabelTextView"
android:gravity="right"
android:text="@string/phone" />
<TextView
style="@style/CustomerLabelTextView"
android:gravity="right"
android:text="@string/fax" />
</TableRow>
</TableLayout>
发布于 2012-09-18 17:26:52
好了,开始工作了。对于那些可能遇到这个问题的人,我在下面添加了代码
<TableRow
android:gravity="right" >
<TextView
android:id="@+id/customerAddress"
style="@style/CustomerTextView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:gravity="right" />
</TableRow>发布于 2012-09-18 15:22:10
尝试向该TableRow添加android:layout_span="2“。
<TableRow
android:layout_span="2"
>
<TextView
style="@style/CustomerLabelTextView"
android:gravity="right"
android:text="@string/customerAddress"
/>
</TableRow>http://developer.android.com/reference/android/widget/TableRow.LayoutParams.html#attr_android:layout_span
https://stackoverflow.com/questions/12472082
复制相似问题