Unit - 5.2
Unit - 5.2
Layouts In
Android
We have different layouts which are subclasses of
ViewGroup class and a typical layout defines the
visual structure for an Android user interface.
Layouts In you can declare your layout using simple XML file
main_layout.xml which is located in the res/layout
Android folder of your project.
There are number of Layouts provided by Android
which you will use in almost all the Android
applications to provide different view, look and feel.
The following layouts are used in our android
Application.
1. Linear Layout
2. Relative Layout
android:layout_width
2
This is the width of the layout.
android:layout_height
3
This is the height of the layout
Layout 4
android:layout_marginTop
This is the extra space on the top side of the layout.
Attributes. 5
android:layout_marginBottom
This is the extra space on the bottom side of the layout.
android:layout_marginLeft
6
This is the extra space on the left side of the layout.
android:layout_marginRight
7
This is the extra space on the right side of the layout
android:layout_gravity
8
This specifies how child Views are positioned.
android:layout_weight
9 This specifies how much of the extra space in the layout
should be allocated to the View.
Layout
android:layout_x
Attributes. 10
This specifies the x-coordinate of the layout.
android:layout_y
11
This specifies the y-coordinate of the layout.
android:layout_width
12
This is the width of the layout.
android:paddingLeft
13
This is the left padding filled for the layout.
android:paddingRight
14
This is the right padding filled for the layout.
Layout
Attributes. 15
android:paddingTop
This is the top padding filled for the layout.
android:paddingBottom
16
This is the bottom padding filled for the layout.
Most commonly used Android View classes
TextView
EditText
Button
Views, ImageView
Buttons ImageButton