Unit III.pptx
Unit III.pptx
res/drawable-hdpi
2 This is a directory for drawable objects that are designed for high-density screens.
res/layout
3
This is a directory for files that define your app's user interface.
res/values
4 This is a directory for other various XML files that contain a collection of resources, such as strings and
colours definitions.
AndroidManifest.xml
5 This is the manifest file which describes the fundamental characteristics of the app and defines each of
its components.
Build.gradle
This is an auto generated file which contains compileSdkVersion, buildToolsVersion, applicationId,
6 minSdkVersion, targetSdkVersion, versionCode and versionName
Layouts in Android
• The basic building block for user interface is a View object which is created from the View class
and occupies a rectangular area on the screen and is responsible for drawing and event handling.
View is the base class for widgets, which are used to create interactive UI components like
buttons, text fields, etc.
• The ViewGroup is a subclass of View and provides invisible container that hold other Views or
other ViewGroups and define their layout properties.
• A layout defines the structure for a user interface in your app, such as in an activity.
• All elements in layout are built using hierarchy of view and viewGroup objects.
Layout Types
❑ Linear Layout (arrenge views horizontally/vertically)
❑ Table Layout (like calculator application in mobile)
❑ Grid Layout (like gallery in mobile)
❑ Constraint Layout (Connecting the view using constraints)
❑ Absolute Layout (Arrange view on selected positions)
❑ Tab Layout (like WhatsApp)
❑ Relative Layout
❑ Frame Layout
Layout in Android
• Android Linear Layout is a view group that aligns all children (views) in either
vertically or horizontally (id, orientation, gravity, divider, weight etc)
Attribute Description
gravity This specifies how an object should position its content, on both the X and Y axes. Possible
values are top, bottom, left, right, center, center_vertical, center_horizontal etc.
ignoreGravity This indicates what view should not be affected by gravity.
layout_above Positions the bottom edge of this view above the given anchor view ID and must be a
reference to another resource, in the form "@[+][package:]type:name"
layout_alignBottom Makes the bottom edge of this view match the bottom edge of the given anchor view ID and
must be a reference to another resource, in the form "@[+][package:]type:name".
layout_alignLeft Makes the left edge of this view match the left edge of the given anchor view ID and must be
a reference to another resource, in the form "@[+][package:]type:name".
layout_alignParentB If true, makes the bottom edge of this view match the bottom edge of the parent. Must be a
ottom boolean value, either "true" or "false".
layout_alignParentE If true, makes the end edge of this view match the end edge of the parent. Must be a boolean
nd value, either "true" or "false".
Layout in Android
• 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. (id, Layout_X, Layout_Y)
Attribute Description
Attribute Description
2 android:layout_width
This is the width of the layout.
3 android:layout_height
This is the height of the layout
4 android:layout_marginTop
This is the extra space on the top side of the layout.
5 android:layout_marginBottom
This is the extra space on the bottom side of the layout.
6 android:layout_marginLeft
This is the extra space on the left side of the layout.
7 android:layout_marginRight
This is the extra space on the right side of the layout.
8 android:layout_gravity
This specifies how child Views are positioned.
Layout Attributes
SR.No Description
9 android:layout_weight
This specifies how much of the extra space in the layout should be allocated to the View.
10 android:layout_x
This specifies the x-coordinate of the layout.
11 android:layout_y
This specifies the y-coordinate of the layout.
12 android:layout_width
This is the width of the layout.
13 android:paddingLeft
This is the left padding filled for the layout.
14 android:paddingRight
This is the right padding filled for the layout.
15 android:paddingTop
This is the top padding filled for the layout.
16 android:paddingBottom
This is the bottom padding filled for the layout.
Thank You…!!!