6
到目前爲止,在我的學習中,我只是平均地傳播了列大小,給了一個/兩個更高的優先級,以根據需要佔用足夠的空間,或手動設置列大小。有沒有辦法讓表格的列等於總寬度的一小部分?
我想知道是否在Android中將列大小設置爲總表大小的一小部分。我想把它分成六份。第一列爲1/6,第二列爲3/6,第三列爲2/6。
有沒有辦法做到這一點?
到目前爲止,在我的學習中,我只是平均地傳播了列大小,給了一個/兩個更高的優先級,以根據需要佔用足夠的空間,或手動設置列大小。有沒有辦法讓表格的列等於總寬度的一小部分?
我想知道是否在Android中將列大小設置爲總表大小的一小部分。我想把它分成六份。第一列爲1/6,第二列爲3/6,第三列爲2/6。
有沒有辦法做到這一點?
您可以通過使用android:layout_span
這裏做,這是一個例子:
<?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"
android:stretchColumns="*">
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:background="#aa0000"
android:text="1/6"
android:gravity="center_horizontal"/>
<TextView
android:background="#00aa00"
android:text="3/6"
android:gravity="center_horizontal"
android:layout_span="3"/>
<TextView
android:background="#0000aa"
android:text="2/6"
android:gravity="center_horizontal"
android:layout_span="2"/>
</TableRow>
</TableLayout>
謝謝。這是完美的:) – NotACleverMan 2010-12-02 15:33:50