我知道有很多關於這個問題的問題已經浮出水面,但我已經閱讀了一堆,但仍然無法讓我的第三欄對齊到右側。Android:無法將TableLayout的重力設置爲正確
<?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="wrap_content"
android:orientation="horizontal"
android:background="#FFFFFF"
android:stretchColumns="2"
>
<TableRow>
<ImageView
android:src="@drawable/blue_light"
android:layout_height="48px"
android:layout_width="48px"
android:padding="3dp"
android:layout_margin="3dp"
android:layout_column="1"/>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10px"
android:layout_gravity="center_vertical"
android:layout_column="2">
<TableRow>
<TextView
android:id="@+id/row_title"
android:textColor="#000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold" />
</TableRow>
<TableRow>
<TextView
android:id="@+id/row_author"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#9E9E9E"
android:textStyle="italic|bold"/>
</TableRow>
</TableLayout>
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="3"
android:layout_gravity="center_vertical|right"
android:gravity="center_vertical|right"
>
<TableRow>
<TextView
android:textColor="#1F9C29"
android:textSize="15dp"
android:id="@+id/row_txt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold" />
</TableRow>
<View
android:layout_height="1dp"
android:background="#000000"
android:layout_marginRight="3dp"
/>
<TableRow>
<TextView
android:textColor="#1B27D1"
android:id="@+id/row_txt2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"/>
</TableRow>
</TableLayout>
</TableRow>
</TableLayout>
我在做什麼錯了?
是的,就是這樣。我轉而在TableLayout中使用嵌套的LinearLayouts來簡化XML。謝謝! – 2010-09-26 16:08:06