Tuesday, June 9, 2015

Android Linear Layout details.

Linera Layout.
I n linearlayout all controls or children are align in single direction.They are in vertical or horizontal direction.
We use android : orientation attribute.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   
android:layout_width="match_parent"
   
android:layout_height="match_parent"
   
android:paddingLeft="10dp"
   
android:paddingRight="10dp"
   
android:orientation="vertical" >
   
<EditText
       
android:layout_width="match_parent"
       
android:layout_height="wrap_content"
       
android:hint="@string/name" />
   
<EditText
       
android:layout_width="match_parent"
       
android:layout_height="wrap_content"
       
android:hint="@string/Address" />
   
<EditText
       
android:layout_width="match_parent"
       
android:layout_height="0dp"
       
android:layout_weight="1"
       
android:gravity="top"
       
android:hint="@string/Permanent" />
   
<Button
       
android:layout_width="100dp"
       
android:layout_height="wrap_content"
       
android:layout_gravity="right"
       
android:text="@string/Add" />
</LinearLayout>
 
What is Layout Weight?
 
Linear Layout assigning a
weight to individual children with the android:layout-weight
attribute.
 
 

No comments:

Post a Comment