2012-03-01 47 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

相關問題