0% found this document useful (0 votes)
57 views

Unit-3 (PPT)

Uploaded by

nik423838
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)
57 views

Unit-3 (PPT)

Uploaded by

nik423838
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/ 25

ANDROID APPLICATION DIRECTORY STRUCTURE

AndroidManifest.xml

 Every project in Android includes a manifest file, which is


AndroidManifest.xml, stored in the root directory of its project hierarchy.
 The manifest file is an important part of our app because it defines the
structure and metadata of our application, its components, and its
requirements.
 This file includes nodes for each of the Activities, Services, Content
Providers and Broadcast Receiver that make the application and using
Intent Filters and Permissions, determines how they co-ordinate with each
other and other applications.
Java Folder :

 The Java folder contains the Java source code files. These files are used as
a controller for controlled UI (Layout file). It gets the data from the Layout
file and after processing that data output will be shown in the UI layout. It
works on the backend of an Android application.
drawable Folder :

 A Drawable folder contains resource type file (something that can be


drawn). Drawables may take a variety of file like Bitmap (PNG, JPEG), Nine
Patch, Vector (XML), Shape, Layers, States, Levels, and Scale.
Layout:

 A layout defines the visual structure for a user interface, such as the UI for
an Android application. This folder stores Layout files that are written in XML
language.
mipmap

 Mipmap folder contains the Image Asset file that can be used in Android
Studio application. You can generate the icon types like Launcher icons,
Action bar and tab icons, and Notification icons.
colors.xml:

 colors.xml file contains color resources of the Android application. Different color
values are identified by a unique name that can be used in the Android
application program.

 Below is a sample colors.xml file:

<?xml version="1.0" encoding="utf-8“?>


<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
</resources>
strings.xml:

 The strings.xml file contains string resources of the Android application. The
different string value is identified by a unique name that can be used in
the Android application program. This file also stores string array by using
XML language.

 Below is a sample strings.xml file:


<resources>
<string name="app_name">MM Polytechnic</string>
</resources>
styles.xml:

 The styles.xml file contains resources of the theme style in the Android application.
This file is written in XML language.

 Below is a sample styles.xml file:

<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
</style>
</resources>
build.gradle(Module: app):

 This defines the module-specific build configurations. Here you can add
dependencies what you need in your Android application.
Fundamentals of UI Design

 Views-
 Views are the basic User Interface class for visual interface elements (commonly known as
controls or widgets).
 All User Interface controls, and the layout classes, are derived from Views.

 ViewGroups-
 View Groups are extensions of the View class that can contain multiple child Views.
 By extending the ViewGroup class, you can create compound controls that are made up of
interconnected child Views.
 The ViewGroup class is also extended to provide the layout managers, such as LinearLayout,
that help you compose User Interfaces.
 Activities-
 Activities represent the window or screen being displayed to the user.
 Activities are the Android equivalent of a Form.
 To display a User Interface, you assign a View or layout to an Activity.
 Android provides several common UI controls, widgets, and layout managers.
Layouts

 It is a type of resource which gives definition on what is drawn on the screen or how
elements are placed on the device’s screen and stored as XML files in the /res/layout
resource directory for the application. It can also be a type of View class to organize
other controls.
 There are many types of layout. Some of which are listed below −
1. Linear Layout
2. Absolute Layout
3. Table Layout
4. Frame Layout
5. Relative Layout
LINEAR LAYOUT

 Linear layout is further divided into horizontal and vertical


layout.
 It means it can arrange views in a single column or in a single
row.
 Here is the code of linear layout(vertical) that includes a text
view.
 A layout that organizes its children into a single horizontal or
vertical row.
 It creates a scrollbar if the length of the window exceeds the <LinearLayout
length of the screen android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
android:orientation=”vertical” >

</LinearLayout>
ABSOLUTELAYOUT

 AbsoluteLayout is based on the simple idea of placing each control at


an absolute position.
 We specify the exact x and y coordinates on the screen for each
control.
 This is not recommended for most UI development (in fact
AbsoluteLayout is currently deprecated) since absolutely positioning
every element on the screen makes an inflexible UI that is much more
difficult to maintain.
 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 is based on the simple idea of placing each control at an
absolute position.
 We specify for the exact x and y corodinates on the screen for every control. So this
recommended for most UI development (in fact Absolute Layout is currentaly
deprecated)since absolute positioning of every element on the screen makes an inflexible UI
that is much more difficult to maintain.
 Consider what happens if a control needs to be added to the user interface UI, we would
have to change the position of every single element that is shifted by the new control. This
allows child views to be positioned at specified X and Y coordinates within the containing
layout view.
<AbsoluteLayout
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
xmlns:android=”http://schemas.android.com/apk/res/android” >
<Button
android:layout_width=”188dp”
android:layout_height=”wrap_content” android:text=”Button”
android:layout_x=”126px”
android:layout_y=”361px” />
</AbsoluteLayout>
TableLayout

 In Android, a TableLayout is a type of layout that arranges its children into


rows and columns, similar to an HTML table.
 It's a part of the Android widget framework that allows for flexible UI
design.
 Each row within a TableLayout is defined using a TableRow object, and
each cell within the row can hold any view object such as a TextView,
Button, ImageView, etc.
 TableLayout:
 A container that organizes its children into a grid of rows and columns.
 Does not display border lines for its rows, columns, or cells.
 Each child of a TableLayout is either a TableRow object or a different View object that will
span all columns.
 TableRow:
 A child of a TableLayout that represents a single row.
 Each child of a TableRow is a cell within that row.
 Cells:
 Contain views that can span multiple columns.
 Can be left empty to create gaps.
 Attributes of TableLayout in Android:
1. stretchColumns: Stretch column attribute is used in Table Layout to change the default width of a column
which is set equal to the width of the widest column but we can also stretch the columns to take up
available free space by using this attribute. 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).
2. shrinkColumns: Shrink column attribute is used to shrink or reduce the width of the column‘s. We can
specify either a single column or a comma delimited list of column numbers for this attribute. The content
in the specified columns word-wraps to reduce their width.
3. collapseColumns: collapse columns attribute is used to collapse or invisible the column’s of a table layout.
These columns are the part of the table information but are invisible.
<TableLayout
xmlns:android=”http://schemas.android.com/apk/res/android”
android:layout_height=”fill_parent” android:layout_width=”fill_parent” >
<TableRow>
<TextView android:text=”User Name:” android:width =”120dp” />
<EditText android:id=”@+id/txtUserName” android:width=”200dp” />
</TableRow>
</TableLayout>
RELATIVELAYOUT

 RelativeLayout enforces to display elements in relations to each other.


 You can specify that, for instance, one UI element can be said to be
placed on the left of another element, or on the bottom of another etc.
 Each UI element can also be positioned according to the layout’s borders
(e.g. aligned to the right)
FRAMELAYOUT

 FrameLayout is a simple and versatile layout in Android that is designed to


hold a single child view. Although it can contain multiple child views, it is
primarily intended to stack them, one on top of the other. This makes it
useful for scenarios where you need to overlay views, such as placing a
TextView on top of an ImageView.

 Useful for overlaying views. For example, you can place a progress spinner
over other content, or a label over an image.
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/sample_image"
android:contentDescription="@string/image_desc" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Overlay Text"
android:textColor="#FFFFFF"
android:background="#AA000000" />

</FrameLayout>

You might also like