<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:id="@+id/text_view_id"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="hello" />
</LinearLayout>
---------------------------------------------------------------------------------
// With Vertical Orientation
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:layout_weight="1">
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="One" />
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="TWO" />
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Three" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="1">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="One"
android:textSize="20pt"
android:background="#aaaa00"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Two"
android:textSize="20pt"
android:background="#aa0000"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Three"
android:textSize="20pt"
android:background="#00aa00"
/>
</LinearLayout>
</LinearLayout>
------------------------------------------------------------------------------------------------------------
// With Horizontal Orientation
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<TextView
android:layout_width="105px"
android:layout_height="fill_parent"
android:text="Red"
android:background="#aa0000"
/>
<TextView
android:layout_width="95px"
android:layout_height="450px"
android:text="Green"
android:background="#00aa00"
/>
<TextView
android:layout_width="85px"
android:layout_height="350px"
android:text="Yellow"
android:background="#ffff00"
/>
<TextView
android:layout_width="75px"
android:layout_height="250px"
android:text="Light Yellow"
android:background="#aaaa00"
/>
</LinearLayout>
----------------------------------------------------------------------------------------------------------
Example
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<Button
android:id="@+id/backbutton"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Back" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="First Name"
/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="100px"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Last Name"
/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="100px"
/>
</LinearLayout>
------------------------------------------------------------------------------------
Example_2
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/backbutton"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Back" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="First Name" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="100px" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Last Name"
/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="100px"
/>
</LinearLayout>
</LinearLayout>
------------------------------------------------------------------------------------
Absolute Layout
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_x="110px"
android:layout_y="110px"
android:text="User Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:layout_x="250px"
android:layout_y="80px"
android:width="100px"
android:layout_width="200dp"
android:layout_height="wrap_content" />
<TextView
android:layout_x="110px"
android:layout_y="200px"
android:text="Password"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:layout_x="250px"
android:layout_y="150px"
android:width="100px"
android:layout_width="200dp"
android:layout_height="wrap_content" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Log In"
android:layout_x="300px"
android:layout_y="300px"/>
</AbsoluteLayout>
---------------------------------------------------------------------------------------------------------------------------
Frame_Layout without gravity attribute
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<TextView android:text="LeftTop"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="RightTop" />
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="CentreTop" />
</FrameLayout>
Frame_Layout with gravity attribute
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<TextView android:text="LeftTop"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="RightTop"
android:layout_gravity="top|right" />
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="CentreTop"
android:layout_gravity="top|center_horizontal" />
</FrameLayout>
--------------------------------------------------------------------------------------
Relative Layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--Text View for Displaying SIGN IN Text At Top of UI-->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="SIGN IN"
android:id="@+id/textView3"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<!--Text View for Displaying Username-->
<TextView
android:id="@+id/userName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="110dp"
android:text="UserName:"
android:textColor="#000000"
android:textSize="20sp" />
<!--Text View for Displaying Password-->
<TextView
android:id="@+id/password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/userName"
android:text="Password:"
android:textColor="#000000"
android:textSize="20sp" />
<!--Edit Text for Filling Username-->
<EditText
android:id="@+id/edt_userName"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_marginTop="100dp"
android:layout_toRightOf="@+id/userName"
android:hint="User Name" />
<!--Edit Text for Filling Password-->
<EditText
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_below="@+id/edt_userName"
android:layout_toRightOf="@+id/password"
android:hint="Password" />
<!--Button for Clicking after filling details-->
<Button
android:id="@+id/btnLogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/password"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:background="#03B424"
android:text="Login"
android:textColor="#ffffff"
android:textStyle="bold" />
</RelativeLayout>
-------------------------------------------------------------------------------------------------
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="1">
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="USER_NAME" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PASSWORD" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<CheckBox
android:id="@+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pizza" />
<RadioButton
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
<TableRow >
<Button
android:id="@+id/loginBtn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="login"
android:textStyle="bold" />
</TableRow>
</TableLayout>
----------------------------------------------------------------------------------------------------------------------------------------