LinearLayout

In a linear layout all the “component”  are arranges in a linear either Horizontally or Vertically and android:orientation an attribute use for LinearLayout orientation.

Example for vertical orientation

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rTop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:gravity="center"
android:padding="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/text1"
android:text="Hello World"
android:textStyle="bold"
android:textColor="#ff00ff"
android:background="#00ff00"
android:textIsSelectable="true"
/>
<TextView
android:gravity="center"
android:padding="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/text2"
android:text="Hello World"
android:textStyle="bold"
android:textColor="#ffffff"
android:background="#ff0000"
android:textIsSelectable="true"
/>
<TextView
android:gravity="center"
android:padding="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/text3"
android:text="Hello World"
android:textStyle="bold"
android:textColor="#ff00ff"
android:background="#0000ff"
android:textIsSelectable="true"
/>

</LinearLayout>
in above example all three text field show on vertical direction.



example for horizontal orientation

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rTop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<TextView
android:gravity="center"
android:padding="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/text1"
android:text="Hello World"
android:textStyle="bold"
android:textColor="#ff00ff"
android:background="#00ff00"
android:textIsSelectable="true"
/>
<TextView
android:gravity="center"
android:padding="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/text2"
android:text="Hello World"
android:textStyle="bold"
android:textColor="#ffffff"
android:background="#ff0000"
android:textIsSelectable="true"
/>
<TextView
android:gravity="center"
android:padding="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/text3"
android:text="Hello World"
android:textStyle="bold"
android:textColor="#ff00ff"
android:background="#0000ff"
android:textIsSelectable="true"
/>
</LinearLayout>

above example all filed show on horizontal direction.