Professional Documents
Culture Documents
Unit – II
Modeling GUI Using Android
Android Layout Types
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.
WebView is a browser that is used to display the web pages in our activity
layout.
• Android ListView:
Layout Attributes
Each layout has a set of attributes which define the visual properties of that layout.
There are few common attributes among all the layouts and there are other attributes
which are specific to that layout. Following are common attributes and will be
applied to all the layouts:
Attribute Description
android:id This is the ID which uniquely identifies the view.
android:layout_width This is the width of the layout.
android:layout_height This is the height of the layout
This is the extra space on the top side of the
android:layout_marginTop
layout.
This is the extra space on the bottom side of the
android:layout_marginBottom
layout.
This is the extra space on the left side of the
android:layout_marginLeft
layout.
This is the extra space on the right side of the
android:layout_marginRight
layout.
android:layout_gravity This specifies how child Views are positioned.
For example, a simple vertical linear layout with a text view and a button looks like
this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I am a TextView" />
<Button android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I am a Button" />
</LinearLayout>
Android UI Controls
We have a different type of UI controls available in android to implement the user
interface for our android applications.
Android ProgressBar:
In android, ProgressBar is a user interface control which is used to indicate the
progress of an operation. For example, downloading a file, uploading a file.
<ProgressBar
android:id="@+id/pBar1"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="50dp"
android:minWidth="200dp"
android:max="100"
android:indeterminate="true"
android:progress="1" />
Attribute Description
ImageView:
ImageView class is used to display any kind of image resource in the android
application.
Attribute Description
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/image" />
<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
</RelativeLayout>