0% found this document useful (0 votes)
75 views5 pages

Layout Manager PDF

The document discusses different Android layout types including LinearLayout, RelativeLayout, TableLayout, AbsoluteLayout, FrameLayout, ListView, and GridView. It provides examples of how to define each type of layout in XML and describes what each layout is used for, such as arranging views vertically or horizontally (LinearLayout), positioning views relative to each other or the parent (RelativeLayout), arranging views into rows and columns (TableLayout), specifying exact positions (AbsoluteLayout), displaying a single item (FrameLayout), displaying items in a vertical scrollable list (ListView), and displaying items in a two-dimensional scrolling grid (GridView).

Uploaded by

Akshay Ramesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views5 pages

Layout Manager PDF

The document discusses different Android layout types including LinearLayout, RelativeLayout, TableLayout, AbsoluteLayout, FrameLayout, ListView, and GridView. It provides examples of how to define each type of layout in XML and describes what each layout is used for, such as arranging views vertically or horizontally (LinearLayout), positioning views relative to each other or the parent (RelativeLayout), arranging views into rows and columns (TableLayout), specifying exact positions (AbsoluteLayout), displaying a single item (FrameLayout), displaying items in a vertical scrollable list (ListView), and displaying items in a two-dimensional scrolling grid (GridView).

Uploaded by

Akshay Ramesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Android LinearLayout is a view group that aligns all children in

either vertically or horizontally.

<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/btnStopService"
android:layout_width="270dp"
android:layout_height="wrap_content"
android:text="stop_service"/>

</LinearLayout>

Android RelativeLayout enables you to specify how child views are positioned relative to
each other. The position of each view can be specified as relative to sibling elements or

relative to the parent.

<RelativeLayout
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/btnStopService"
android:layout_width="270dp"
android:layout_height="wrap_content"
android:text="stop_service"/>

</RelativeLayout>

Android TableLayout going to be arranged groups of views into rows and columns. You will
use the <TableRow> element to build a row in the table. Each row has zero or more cells;
each cell can hold one View object.
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<TextView
android:text="Time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1" />

<TextClock
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textClock"
android:layout_column="2" />

</TableRow>

</TableLayout>

An Absolute Layout lets you specify exact locations (x/y coordinates) of its children.
Absolute layouts are less flexible and harder to maintain than other types of layouts without
absolute positioning.
<AbsoluteLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="OK"
android:layout_x="50px"
android:layout_y="361px" />

</AbsoluteLayout>

Frame Layout is designed to block out an area on the screen to display a single item.
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<ImageView
android:src="@drawable/ic_launcher"
android:scaleType="fitCenter"
android:layout_height="250px"
android:layout_width="250px"/>

</FrameLayout>

Android ListView is a view which groups several items and display them in vertical
scrollable list.

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"

<ListView
android:id="@+id/mobile_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>

</LinearLayout>

Android GridView shows items in two-dimensional scrolling grid (rows & columns) and the
grid items are not necessarily predetermined but they automatically inserted to the layout
using a ListAdapter

<GridView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"

/>

You might also like