使用tp生成像android这样的数据输入表格的最佳布局是什么:
我应该使用垂直线性布局,每个项目都采用horizental布局吗?或相对布局。我不能使用表格布局,因为每个文本条目可能都有自己的宽度。
由于
答案 0 :(得分:9)
作为主要布局,您可以使用垂直线性布局,对于每一行,线性布局为水平,设置宽度为fill_parent。 对于4个第一行(数据形式容器),在设置宽度时,使用“0 dip”作为宽度并根据需要设置layout_weight的比例,为下一行保留相同的值以保持对齐。别忘了将重力设置为第一列
<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比例。
想想,这对你有帮助......
答案 1 :(得分:1)
相对布局将很有用,并使用padding属性将UI作为图像获取
答案 2 :(得分:0)
根据我的观点,你可以选择线性布局,它很容易处理
一个垂直方向的线性布局 和5个水平方向的线性布局