0
所以,我通过膨胀布局文件从代码创建TableLayout。我试图让第一行跨越两列,每一行都包含两个TextView:key和value。问题是这个值可能会很长,所以我在TableLayout xml中设置android:stretchColumns
,android:shrinkColumns
。现在键列和值列看起来很好,但首先跨越,标题是更大的屏幕大小。Android,在TableLayout中设置列大小
现在我的档案情况是这样的:
tale_row.xml:
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:paddingLeft="10dp"
android:paddingRight="10dp" >
<TextView
android:id="@+id/key"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/gray"
android:textStyle="bold"
android:layout_marginRight="10dp" />
<TextView
android:id="@+id/value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/black" />"
</TableRow>
header_row.xml:
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/header"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_span="2"
style="@style/group_separator_style"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" />
</TableRow>
table.xml:
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="1" >
</TableLayout>
任何想法,什么coul d是原因吗?将属性clipChildren
和clipToPadding
设置为true并没有帮助。
使用layout_width在标题单元格 – njzk2 2013-03-01 08:40:58
=“match_parent”可惜的是,它并没有帮助 – Seraphis 2013-03-01 19:54:04