Jos*_*ing 3 android children width tablelayout tablerow
我目前TableLayout有3行,每行有一个孩子,a TextView.我的问题是TextViews宽度不是"match_parent"他们应该的.我已经按照不为它们定义高度和宽度的程序(如文档所述)但由于某种原因问题仍然存在.
我已经打开了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>
Run Code Online (Sandbox Code Playgroud)
另外,我将包含xml文件@drawable/textlines.也许问题在那里?(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>
Run Code Online (Sandbox Code Playgroud)
Luk*_*rog 13
我不知道为什么会这样,但你可以通过添加:
android:layout_weight="1"
Run Code Online (Sandbox Code Playgroud)
给你的孩子TextView,或者添加:
android:stretchColumns="0"
Run Code Online (Sandbox Code Playgroud)
你的父母TableLayout.
| 归档时间: |
|
| 查看次数: |
4299 次 |
| 最近记录: |