Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 957
Hassan Mokdad Avatar asked Mar 01 '12 14:03

Hassan Mokdad


People also ask

What is layout and types of layout in Android?

Android Layout TypesTableLayout is a view that groups views into rows and columns. AbsoluteLayout enables you to specify the exact location of its children. The FrameLayout is a placeholder on screen that you can use to display a single view. ListView is a view group that displays a list of scrollable items.

What is the layout of Android apps?

Android Layout is used to define the user interface that holds the UI controls or widgets that will appear on the screen of an android application or activity screen. Generally, every application is a combination of View and ViewGroup.


1 Answers

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

like image 58
Yvan RAJAONARIVONY Avatar answered Nov 15 '22 04:11

Yvan RAJAONARIVONY