Has*_*dad 5 android android-layout
什么是最好的布局使用tp生成像android这样的数据输入表单:

我应该使用垂直线性布局,每个项目都采用horizental布局吗?或相对布局.我不能使用表格布局,因为每个文本条目可能都有自己的宽度.
谢谢
小智 10
作为主要布局,您可以使用垂直线性布局,并且对于每一行,线性布局水平,设置宽度为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>
Run Code Online (Sandbox Code Playgroud)
这样做,最后一行,每列0.5比例.
想想,这对你有帮助......
| 归档时间: |
|
| 查看次数: |
5338 次 |
| 最近记录: |