0% found this document useful (0 votes)
15 views4 pages

Layouts and Thier Attributes

The document provides an overview of various Android layout types including LinearLayout, RelativeLayout, ConstraintLayout, FrameLayout, TableLayout, and GridLayout, along with their key attributes. Each layout type is described with its primary function and important attributes that control the arrangement and positioning of child views. The information is aimed at helping developers understand how to effectively use these layouts in Android applications.

Uploaded by

abhaysonone0
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)
15 views4 pages

Layouts and Thier Attributes

The document provides an overview of various Android layout types including LinearLayout, RelativeLayout, ConstraintLayout, FrameLayout, TableLayout, and GridLayout, along with their key attributes. Each layout type is described with its primary function and important attributes that control the arrangement and positioning of child views. The information is aimed at helping developers understand how to effectively use these layouts in Android applications.

Uploaded by

abhaysonone0
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/ 4

V2V EdTech LLP

Layouts and their attributes

1. LinearLayout

Arranges child views linearly in a single direction (vertically or horizontally).

Important Attributes:

android:orientation="vertical|horizontal" → Defines whether children are arranged in a row


(horizontal) or a column (vertical).

android:gravity="center|left|right|top|bottom" → Specifies how child views align inside the


layout.

android:layout_weight="1" → Distributes extra space among children proportionally.

android:baselineAligned="true|false" → Aligns text baselines of child views (mostly for mixed


text and image views).

android:divider="?android:attr/dividerVertical" → Adds a divider line between children.

android:showDividers="beginning|middle|end" → Specifies where dividers appear.

android:weightSum="3" → Defines the total sum of layout weights for all children.

2. RelativeLayout

Arranges child views relative to each other or the parent layout.

Important Attributes:

android:layout_alignParentTop="true" → Aligns the view to the top of the parent.

android:layout_alignParentBottom="true" → Aligns the view to the bottom of the parent.

android:layout_centerInParent="true" → Centers the view both horizontally and vertically.


V2V EdTech LLP

android:layout_centerHorizontal="true" → Centers the view horizontally.

android:layout_centerVertical="true" → Centers the view vertically.

android:layout_below="@id/view1" → Positions the view below another view.

android:layout_above="@id/view1" → Positions the view above another view.

android:layout_toRightOf="@id/view1" → Places the view to the right of another view.

android:layout_toLeftOf="@id/view1" → Places the view to the left of another view.

3. ConstraintLayout

A flexible and efficient layout that allows positioning child views with constraints.

Important Attributes:

app:layout_constraintTop_toTopOf="parent" → Aligns the top of the view to the top of the


parent.

app:layout_constraintBottom_toBottomOf="@id/view1" → Aligns the bottom of the view to


another view.

app:layout_constraintStart_toStartOf="parent" → Aligns the start of the view to the start of the


parent (use instead of Left for RTL support).

app:layout_constraintEnd_toEndOf="@id/view1" → Aligns the end of the view to another view.

app:layout_constraintHorizontal_bias="0.5" → Controls the horizontal position (0 = left, 1 =


right, 0.5 = center).

app:layout_constraintVertical_bias="0.2" → Controls the vertical position (0 = top, 1 = bottom).

app:layout_constraintWidth_default="wrap" → Sets the default width behavior (wrap, spread, or


percent).
V2V EdTech LLP

4. FrameLayout

A single-child layout where all children are stacked on top of each other.

Important Attributes:

android:foreground="?attr/selectableItemBackground" → Sets a foreground (useful for touch


feedback).

android:foregroundGravity="center" → Aligns the foreground inside the layout.

android:measureAllChildren="true" → Forces all children to be measured even if they are


GONE.

5. TableLayout

Arranges child views in rows and columns, similar to a table.

Important Attributes:

android:stretchColumns="1,2" → Expands specified columns to fill available space.

android:shrinkColumns="0,1" → Allows columns to shrink if needed.

android:collapseColumns="2" → Hides the specified column.

android:layout_column="1" → Positions a view in a specific column.

6. GridLayout

Divides the screen into a flexible grid of rows and columns.


V2V EdTech LLP

Important Attributes:

android:rowCount="3" → Sets the number of rows in the layout.

android:columnCount="2" → Sets the number of columns.

android:layout_row="1" → Places the view in a specific row.

android:layout_column="0" → Places the view in a specific column.

android:layout_rowSpan="2" → Makes the view span multiple rows.

android:layout_columnSpan="2" → Makes the view span multiple columns.

All the Best!!


With Regards
Darshan Khapekar
Team V2V

You might also like