3
我有一个TableLayout
目前有3行,每行有一个孩子,一个TextView
。我的问题是,TextViews
宽度不是"match_parent"
,因为他们应该。我遵循了没有为他们定义高度和宽度的程序(like the documentation says),但由于某些原因,问题仍然存在。Android TableRow儿童问题
我打开了hierarchyviewer
并查看了数值,TableRow
填满了宽度,但TextView
未填充该行,它只是包装内容。完整的XML布局如下,有没有人有任何想法?
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:background="@drawable/textlines"
android:text="@string/text1_string"
android:textColor="#000000"
android:padding="5dp">
</TextView>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:background="@drawable/textlines"
android:text="@string/text1_string"
android:textColor="#000000"
android:padding="5dp">
</TextView>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:background="@drawable/textlines"
android:text="@string/text1_string"
android:textColor="#000000"
android:padding="5dp">
</TextView>
</TableRow>
</TableLayout>
另外,我将包含@drawable/textlines
的xml文件。问题可能在那里? (textlines
代码是从这里提供的关于边界问题的解决方案中提取的),我非常理解它,我不认为它会影响我的问题,但我可能是错的。无论如何,那就是:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape
android:shape="rectangle">
<stroke android:width="1dp" android:color="#FF000000" />
<solid android:color="#FFDDDDDD" />
</shape>
</item>
<item android:top="1dp" android:bottom="1dp">
<shape
android:shape="rectangle">
<stroke android:width="1dp" android:color="#FFDDDDDD" />
<solid android:color="#00000000" />
</shape>
</item>
</layer-list>
我想你的意思是: '机器人:layout_weight = “1”' 到TextView的... – 2012-09-01 20:15:45
@ DanDar3是,宽度设置为1不能解决任何问题。如果您认为可以更正问题,请不要害怕编辑问题/答案。 – Luksprog 2012-09-02 06:54:00
用于以编程方式扩展所有列*使用setStretchAllColumns(true); – 2014-01-29 17:12:18