使用 tp 在 android 中生成像这样的数据输入表单的最佳布局是什么:
我应该使用垂直线性布局,每个项目都使用水平布局吗?或相对布局。我不能使用表格布局,因为每个文本条目可能都有自己的宽度。
谢谢
最佳答案
作为主布局,您可以使用垂直线性布局,对于每一行,水平线性布局,将宽度设置为 fill_parent。 对于前 4 行(数据表单容器),在设置宽度时,宽度使用“0 dip”,并根据需要为 layout_weight 设置一个比例,为保持对齐,下 3 行保持相同的值。不要忘记为第一列设置正确的引力
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="50dip"
android:paddingRight="50dip">
<TextView
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:text="label"
android:gravity="right"/>
<EditText
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.7"
android:hint="value"
android:layout_marginLeft="15dip"/>
</LinearLayout>
</LinearLayout>
这样做,最后一行每列的比例为 0.5。
想想,这对你有帮助...
关于android - 在 android 中使用什么布局来生成数据输入表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9517562/