0% found this document useful (0 votes)
28 views41 pages

AND1

The document discusses various Android layouts including LinearLayout, AbsoluteLayout, FrameLayout, TableLayout, and RelativeLayout. It provides details on the main attributes and properties of each layout. LinearLayout displays elements in a linear fashion horizontally or vertically. AbsoluteLayout allows exact positioning but is less flexible. FrameLayout is used to display a single child view. TableLayout arranges views into rows and columns. RelativeLayout positions views relative to each other or the parent container.
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)
28 views41 pages

AND1

The document discusses various Android layouts including LinearLayout, AbsoluteLayout, FrameLayout, TableLayout, and RelativeLayout. It provides details on the main attributes and properties of each layout. LinearLayout displays elements in a linear fashion horizontally or vertically. AbsoluteLayout allows exact positioning but is less flexible. FrameLayout is used to display a single child view. TableLayout arranges views into rows and columns. RelativeLayout positions views relative to each other or the parent container.
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/ 41

Android

Linear Layout
• elements are displayed in linear fashion
• displayed according to its orientation
• horizontal or vertical
Main Attributes In Linear Layout
• orientation
• gravity
• layout_weight
• weightSum
AbsoluteLayout
• 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.
• In Android, an Absolute Layout is a
layout used to design the custom
layouts.
• In this layout you can specify the
exact location of its children by using
x and y coordinates.

AbsoluteLayout
• Try opening the same layout in different size Emulator and you
will see it doesn’t fit in different size device.
• That’s why Android has depreciated the use of Absolute Layout.
Frame Layout
• designed to block out an area on the screen to display a single
item
• used to hold a single child view
Frame Layout
• We can add multiple children to a FrameLayout
• control their position by assigning gravity to each child
• android:layout_gravity attribute.
FrameLayout Attributes
• android:visibility
• This determine whether to make the view visible, invisible or
gone.
• visible – the view is present and also visible
• invisible – The view is present but not visible
• gone – The view is neither present nor visible
Android Table Layout
• arrange groups of views into rows and
columns
• <TableRow> element to build a row in the
table
• Each row has zero or more cells; each cell
can hold one View object
• TableLayout containers do not display
border lines for their rows, columns, or cells
• Total width of a table is defined by its
parent container
• Column can be both stretchable and
shrinkable
stretchColumns
• to change the default width of a column
• The value that assigned to this attribute can be a single column
number or a comma delimited list of column numbers (1, 2,
3…n)
• If the value is 1 then the second column is stretched to take up
any available space in the row
• If the value is 0,1 then both the first and second columns of
table are stretched
• If the value is ‘*’ then all the columns are stretched to take up
the available space
shrinkColumns
• Shrink column attribute is used to shrink or reduce the width of
the column‘s
• If the value is 0 then the first column’s width shrinks or reduces
by word wrapping
• If the value is 0,1 then both first and second columns are shrinks
• If the value is ‘*’ then the content of all columns is word
wrapped to shrink their widths
collapseColumns: collapse columns attribute is used to
collapse or invisible the column’s
<TableLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:stretchColumns="1">
<TableRow>
<TextView/>
</TableRow>
<TableRow>
<TextView/>
<EditText/>
</TableRow>
<TableRow>
<TextView/>
<EditText/>
</TableRow>
<TableRow>
<Button/>
</TableRow>
</TableLayout >
Relative Layout
• Very flexible layout used in
android for custom layout design
• flexibility to position our view
based on the relative or sibling
view’s position
• Relative layout is the most used
layout after the Linear Layout in
Android
• It allow its child view to position
relative to each other or relative
to the container
• For example, in the below image
you can see content is placed in
related to Heading
1.above:
• Position the bottom edge of the view above the given anchor
view ID and must be a reference of the another resource in the
form of id
• Example, android:layout_above=”@id/textView”
2. alignBottom:
• alignBottom is used to makes the bottom edge of the view
match the bottom edge of the given anchor view ID and it must
be a reference to another resource, in the form of id
• Example: android:layout_ alignBottom =”@id/button1″
3. alignLeft:
• alignLeft is used to make the left edge of the view match the
left edge of the given anchor view ID and must be a reference
to another resource,
• Example: android:layout_ alignLeft =”@+id/button1″.
4. alignRight
• alignRight property is used to make the right edge of this view
match the right edge of the given anchor view ID
• example: android:layout_alignRight=”@+id/button1″
5.alignStart
• alignStart property is used to makes the start edge of this view
match the start edge of the given anchor view ID
• example: android:layout_alignStart=”@+id/button1″
6. alignTop:
• alignTop property is used to makes the top edge of this view
match the top edge of the given anchor view ID
• example: android:layout_alignTop=”@+id/button1″.

You might also like