我有一个包含两列和两行的 tableLayout,两行和最后一列的宽度都有 match_parent,但布局没有填充父宽度,它的表现就像有 wrap_content 一样。
这是代码:
<TableLayout android:layout_width="match_parent">
<TableRow android:layout_width="match_parent">
<TextView
android:layout_width="wrap_content"
android:text="static" />
<EditText
android:layout_width="match_parent"
android:text="text" />
</TableRow>
<TableRow android:layout_width="match_parent">
<TextView
android:layout_width="wrap_content"
android:text="static2" />
<EditText
android:layout_width="match_parent"
android:text="text2" />
</TableRow>
</TableLayout>
对于具有父级宽度的每行,我需要做什么?
PS:我工作的地方不允许我发布我的代码,所以我写了一个尽可能接近我的代码的代码。不知道对不对,无法测试。
试试这段代码,我想它会对你有所帮助:
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TableRow android:layout_width="match_parent" >
<TextView
android:layout_width="fill_parent"
android:layout_weight="1"
android:text="static" />
<EditText
android:layout_width="match_parent"
android:layout_weight="1"
android:text="text" />
</TableRow>
<TableRow android:layout_width="match_parent" >
<TextView
android:layout_width="fill_parent"
android:layout_weight="1"
android:text="static2" />
<EditText
android:layout_width="match_parent"
android:layout_weight="1"
android:text="text2" />
</TableRow>
</TableLayout>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)