Hassan Mokdad
Hassan Mokdad

Reputation: 5902

What layout to use to produce a data entry form in android

What is the best layout to use tp produce a data entry form like this one in android: entry form

Should I use a vertical linear layout,, with a horizental layout for each of the items? or a relative layout. I can't use a table layout because each text entry might have it's own width.

Thanks

Upvotes: 5

Views: 5933

Answers (3)

Yvan RAJAONARIVONY
Yvan RAJAONARIVONY

Reputation: 571

As main layout, you can use a linear layout vertical, and for each row, a linear layout horizontal, setting width to fill_parent. For the 4 first rows (data form container), when setting width, use "0 dip" for width and set a proportion to layout_weight as you need, keep the same value for the 3 next row in order to keep the alignement. Dont forget to set gravity right fo first column

<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>

Do so, for last row with 0.5 proportion for each column.

Think, that helped you...

Upvotes: 10

Avi Kumar
Avi Kumar

Reputation: 4433

As per my view you can pick linear layout it will be easy to handle

one Linear layout with vertical orientation and 5 linear layouts with horizontal orientation

Upvotes: 0

Mohamed Ahmed
Mohamed Ahmed

Reputation: 11

relative layout will be useful and use padding attribute to obtain the UI as image

Upvotes: 1

Related Questions