jon*_*nrz 11 android android-layout android-tablelayout
我有一个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>
Run Code Online (Sandbox Code Playgroud)
对于具有父级宽度的每一行,我需要做什么?
Ps:我工作的地方不允许我发布我的代码,所以我编写了尽可能接近我的代码的代码.我不知道它是不对的,我无法测试.
and*_*dev 26
试试这段代码,我想它会对你有所帮助:
<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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12880 次 |
| 最近记录: |