Tôi muốn vẽ một bảng trong đó cột cuối cùng phải nằm ở bên phải nhất của bảng.Cột căn chỉnh phải trong bố cục bảng android
Đây là cách dòng của bảng trông giống như:
Admin (2)New
Network (2)New
Và đây là cách nó nên là:
Admin (2) New
Network (2) New
XML:
<?xml version="1.0" encoding="utf-8"?>
<!-- row.xml -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="45dp"
android:gravity="center" android:background="@color/list_bg">
<TableLayout android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableRow>
<ImageView android:id="@+id/t1" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView android:id="@+id/t2" android:typeface="normal"
android:singleLine="true" android:textSize="14sp" android:textStyle="normal"
android:layout_width="wrap_content" android:textColor="#000000"
android:layout_height="wrap_content" />
<TextView android:id="@+id/t10" android:typeface="normal"
android:singleLine="true" android:text=" " android:textSize="14sp"
android:textStyle="normal" android:layout_width="wrap_content"
android:textColor="#000000" android:layout_height="wrap_content" />
<TextView android:id="@+id/t4" android:typeface="normal"
android:visibility="gone" android:singleLine="true" android:text="("
android:textSize="14sp" android:textStyle="normal"
android:layout_width="wrap_content" android:textColor="#000000"
android:layout_height="wrap_content" />
<TextView android:id="@+id/t5" android:typeface="normal"
android:visibility="gone" android:singleLine="true"
android:textSize="14sp" android:textStyle="normal"
android:layout_width="wrap_content" android:textColor="#000000"
android:layout_height="wrap_content" />
<TextView android:id="@+id/t6" android:typeface="normal"
android:visibility="gone" android:singleLine="true" android:text=")"
android:textSize="14sp" android:textStyle="normal"
android:layout_width="wrap_content" android:textColor="#000000"
android:layout_height="wrap_content" />
<ImageView android:id="@+id/t3" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView android:id="@+id/t7" android:typeface="normal"
android:visibility="visible" android:singleLine="true" android:text="New"
android:textSize="14sp"
android:textStyle="normal" android:layout_width="wrap_content"
android:textColor="#000000" android:layout_height="wrap_content" />
</TableRow>
</TableLayout>
</RelativeLayout>
Trong t7 xml này nên ngay bên phải của bảng, làm thế nào để làm điều này?
Bạn có thể nhóm LinearLayout và các chế độ xem khác để làm cho TableRow của bạn có nhiều cột hơn. Vì vậy, thay vì có một hàng bảng duy nhất với 8 cột, bạn sẽ có một hàng duy nhất với hai cột (như ví dụ của bạn). – Cookster