有没有办法让表格的列等于总宽度的一小部分?
问题描述:
到目前为止,在我的学习中,我只是平均地传播了列大小,给了一个/两个更高的优先级,以根据需要占用足够的空间,或手动设置列大小。有没有办法让表格的列等于总宽度的一小部分?
我想知道是否在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