【发布时间】:2012-09-02 14:52:57
【问题描述】:
我有一个TableLayout,目前有 3 行,每行有一个孩子,TextView。我的问题是TextViews 的宽度没有达到应有的"match_parent"。我遵循了不为它们定义高度和宽度的过程(like the documentation says),但由于某种原因,问题仍然存在。
我打开了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>
【问题讨论】:
标签: android width tablelayout children tablerow