2012-03-01 46 views
5

数据输入表单什么是使用TP产生一个数据输入窗体像这样的android系统中最好的布局: entry form什么布局,使用产生的Android

我应该使用一个垂直线性布局,,用每个项目的角度布局?或相对布局。我无法使用表格布局,因为每个文本条目可能都有自己的宽度。

由于

回答

9

作为主布局,可以使用垂直线性布局,并且对于每一行,水平线性布局,设置宽度为FILL_PARENT。 对于前4行(数据表单容器),当设置宽度时,根据需要使用“0 dip”作为宽度,并为layout_weight设置一个比例,为了保持对齐,为下一行保留相同的值。不要忘记设置重力右FO第一列

<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

相对布局将是有用的,并使用填充属性以获得UI作为图像

0

按我视图你可以选择线性布局这将是容易处理

一个线性布局垂直方向 和5个水平方向的线性布局

+0

哪个提供更好的性能,线性布局或相对布局 – 2012-03-01 14:24:21

+0

看到了这个文件,将帮助您http://developer.android.com/resources/articles/layout- tricks-efficiency.html – 2012-03-01 14:29:41

+0

线性更简单,但性能明智相对更好 – 2012-03-01 14:31:06

相关问题