advance android application development workshop day 2
DESCRIPTION
10 Days Android Workshop at L J Institute of engineering and technology delivered by Cresco Solution visit: http://www.crescosolution.com/android-workshop-at-l-j-institute-of-engineering-and-technology-ahmedabad/TRANSCRIPT
![Page 1: Advance Android application development workshop day 2](https://reader031.vdocuments.us/reader031/viewer/2022020218/559dce981a28ab54368b4821/html5/thumbnails/1.jpg)
![Page 2: Advance Android application development workshop day 2](https://reader031.vdocuments.us/reader031/viewer/2022020218/559dce981a28ab54368b4821/html5/thumbnails/2.jpg)
www.crescosolution.com
Defines the architecture for
the UI in an Activity
Visual structure for a user interface
Layout resources are stored as XML
files in the /res/layout
resource directory
Simply a template for a user interface
screen
Portion of a screen
Layout
![Page 3: Advance Android application development workshop day 2](https://reader031.vdocuments.us/reader031/viewer/2022020218/559dce981a28ab54368b4821/html5/thumbnails/3.jpg)
www.crescosolution.com
Types of Layout
Linear layout
Relative layout
Table layout
Absolute layout
Frame layout
![Page 4: Advance Android application development workshop day 2](https://reader031.vdocuments.us/reader031/viewer/2022020218/559dce981a28ab54368b4821/html5/thumbnails/4.jpg)
www.crescosolution.com
Linear Layout
The direction of the row can be set by
callingsetOrientation()
![Page 5: Advance Android application development workshop day 2](https://reader031.vdocuments.us/reader031/viewer/2022020218/559dce981a28ab54368b4821/html5/thumbnails/5.jpg)
www.crescosolution.com
Linear Layout
<?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:paddingLeft="16dp"android:paddingRight="16dp"android:orientation="vertical" ><EditTextandroid:layout_width="fill_parent"android:layout_height="wrap_content"android:hint="@string/to" /><EditTextandroid:layout_width="fill_parent"android:layout_height="wrap_content"android:hint="@string/subject" />
![Page 6: Advance Android application development workshop day 2](https://reader031.vdocuments.us/reader031/viewer/2022020218/559dce981a28ab54368b4821/html5/thumbnails/6.jpg)
www.crescosolution.com
Linear Layout
<EditTextandroid:layout_width="fill_parent"android:layout_height="0dp"android:layout_weight="1"android:gravity="top"android:hint="@string/message" /><Buttonandroid:layout_width="100dp"android:layout_height="wrap_content"android:layout_gravity="right"android:text="@string/send" />
</LinearLayout>
![Page 7: Advance Android application development workshop day 2](https://reader031.vdocuments.us/reader031/viewer/2022020218/559dce981a28ab54368b4821/html5/thumbnails/7.jpg)
www.crescosolution.com
Relative Layout
Use “above, below, leftand right”
Allow to position your component to
display in anywhere
Most flexible layout
View group that displays child views
![Page 8: Advance Android application development workshop day 2](https://reader031.vdocuments.us/reader031/viewer/2022020218/559dce981a28ab54368b4821/html5/thumbnails/8.jpg)
www.crescosolution.com
Relative Layout
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"android:layout_height="fill_parent"android:paddingLeft="16dp"android:paddingRight="16dp" ><EditTextandroid:id="@+id/name"android:layout_width="fill_parent"android:layout_height="wrap_content"android:hint="@string/reminder" /><Buttonandroid:id="@+id/dates"android:layout_width="100dp"android:layout_height="wrap_content"android:layout_below="@id/name"android:layout_alignParentLeft="true"android:text="@string/date"/>
![Page 9: Advance Android application development workshop day 2](https://reader031.vdocuments.us/reader031/viewer/2022020218/559dce981a28ab54368b4821/html5/thumbnails/9.jpg)
www.crescosolution.com
Relative Layout
<Buttonandroid:id="@+id/times"android:layout_width="100dp"android:layout_height="wrap_content"android:layout_below="@id/name"android:text="@string/time"android:layout_alignParentRight="true" /><Buttonandroid:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_alignParentBottom="true"android:text="@string/done" />
</RelativeLayout>
![Page 10: Advance Android application development workshop day 2](https://reader031.vdocuments.us/reader031/viewer/2022020218/559dce981a28ab54368b4821/html5/thumbnails/10.jpg)
www.crescosolution.com
Table Layout
Arranges its children into rows and columns
Each row has zero or more cells; each cell can hold one View object
TableLayout is comprised of
TableRow controls—one for each row in your
table
just like the standard table layout in HTML, <tr> and <td>
grid of a made up of rows and
columns
Collections of rows and cols
![Page 11: Advance Android application development workshop day 2](https://reader031.vdocuments.us/reader031/viewer/2022020218/559dce981a28ab54368b4821/html5/thumbnails/11.jpg)
www.crescosolution.com
Table Layout
<?xml version="1.0" encoding="utf-8"?><TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:shrinkColumns="*" android:stretchColumns="*"
android:background="#ffffff"><!-- Row 1 with single column --><TableRowandroid:layout_height="wrap_content"android:layout_width="fill_parent"android:gravity="center_horizontal"><TextViewandroid:layout_width="match_parent"
android:layout_height="wrap_content"android:textSize="18dp" android:text="Row 1"
android:layout_span="3"android:padding="18dip" android:background="#b0b0b0"android:textColor="#000"/></TableRow>
![Page 12: Advance Android application development workshop day 2](https://reader031.vdocuments.us/reader031/viewer/2022020218/559dce981a28ab54368b4821/html5/thumbnails/12.jpg)
www.crescosolution.com
Table Layout
<!-- Row 2 with 3 columns --><TableRowandroid:id="@+id/tableRow1"android:layout_height="wrap_content"android:layout_width="match_parent"><TextViewandroid:id="@+id/TextView04" android:text="Row 2
column 1"android:layout_weight="1" android:background="#dcdcdc"android:textColor="#000000"android:padding="20dip" android:gravity="center"/><TextViewandroid:id="@+id/TextView04" android:text="Row 2
column 2"android:layout_weight="1"
android:background="#d3d3d3"android:textColor="#000000"android:padding="20dip" android:gravity="center"/><TextViewandroid:id="@+id/TextView04" android:text="Row 2
column 3"android:layout_weight="1" android:background="#cac9c9"android:textColor="#000000"android:padding="20dip" android:gravity="center"/></TableRow>
![Page 13: Advance Android application development workshop day 2](https://reader031.vdocuments.us/reader031/viewer/2022020218/559dce981a28ab54368b4821/html5/thumbnails/13.jpg)
www.crescosolution.com
Table Layout
<!-- Row 3 with 2 columns --><TableRowandroid:layout_height="wrap_content"android:layout_width="fill_parent"android:gravity="center_horizontal"><TextViewandroid:id="@+id/TextView04" android:text="Row 3
column 1"android:layout_weight="1" android:background="#b0b0b0"android:textColor="#000000"android:padding="20dip" android:gravity="center"/>
<TextViewandroid:id="@+id/TextView04" android:text="Row 3
column 2"android:layout_weight="1" android:background="#a09f9f"android:textColor="#000000"android:padding="20dip" android:gravity="center"/></TableRow>
</TableLayout>
![Page 14: Advance Android application development workshop day 2](https://reader031.vdocuments.us/reader031/viewer/2022020218/559dce981a28ab54368b4821/html5/thumbnails/14.jpg)
www.crescosolution.com
Absolute Layout
The simple idea of placing each control at an absolute position
Specify the exact x and y coordinates on the screen for each control
Deprecated in android sdk.
![Page 15: Advance Android application development workshop day 2](https://reader031.vdocuments.us/reader031/viewer/2022020218/559dce981a28ab54368b4821/html5/thumbnails/15.jpg)
www.crescosolution.com
Absolute Layout
<?xml version="1.0" encoding="utf-8"?><AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"android:layout_height="fill_parent">
<Buttonandroid:layout_width="100dp"android:layout_height="wrap_content"android:text="OK"android:layout_x="50px"android:layout_y="361px" />
<Buttonandroid:layout_width="100dp"android:layout_height="wrap_content"android:text="Cancel"android:layout_x="225px"android:layout_y="361px" />
</AbsoluteLayout>
![Page 16: Advance Android application development workshop day 2](https://reader031.vdocuments.us/reader031/viewer/2022020218/559dce981a28ab54368b4821/html5/thumbnails/16.jpg)
www.crescosolution.com
Frame Layout
Designed to display a single item at a time
Multiple elements within a Frame Layout but each element will be positioned based on the top left of the screen
Displayed overlapping
![Page 17: Advance Android application development workshop day 2](https://reader031.vdocuments.us/reader031/viewer/2022020218/559dce981a28ab54368b4821/html5/thumbnails/17.jpg)
www.crescosolution.com
Frame Layout
<?xml version="1.0" encoding="utf-8"?><FrameLayout
android:layout_width="fill_parent"android:layout_height="fill_parent"xmlns:android="http://schemas.android.c
om/apk/res/android"><ImageViewandroid:src="@drawable/ic_launcher"android:scaleType="fitCenter"android:layout_height="fill_parent"android:layout_width="fill_parent"/><TextViewandroid:text="This is Frame Layout!!!"android:textSize="24px"android:textColor="#cc0000"android:layout_height="fill_parent"android:layout_width="fill_parent"android:gravity="top"/>
![Page 18: Advance Android application development workshop day 2](https://reader031.vdocuments.us/reader031/viewer/2022020218/559dce981a28ab54368b4821/html5/thumbnails/18.jpg)
www.crescosolution.com
Frame Layout
<TextViewandroid:text="Learn Android Development At
onlyMobilePro.com"android:textColor="#A60024"android:layout_height="fill_parent"android:layout_width="fill_parent"android:textSize="20sp"android:gravity="center"/>
</FrameLayout>
![Page 19: Advance Android application development workshop day 2](https://reader031.vdocuments.us/reader031/viewer/2022020218/559dce981a28ab54368b4821/html5/thumbnails/19.jpg)
www.crescosolution.com
Activity
Provides a screen with which users can interact
Window, in which to draw its
user interface
Consists of multiple activities
One activity in an
application is specified
as the "main" activity
You must declare
your activity in
the manifest
file
![Page 20: Advance Android application development workshop day 2](https://reader031.vdocuments.us/reader031/viewer/2022020218/559dce981a28ab54368b4821/html5/thumbnails/20.jpg)
www.crescosolution.com
Activity
Called when the activity will start interacting with the user , At this point your activity is at the top of the activity stack, with user input going to it.
OnResume()
Called when the activity is becoming visible to the user
OnStart()
Called when the activity is first created , This is where you should do all of your normal static setup , create views, bind data to lists, etc .
Oncreate()
![Page 21: Advance Android application development workshop day 2](https://reader031.vdocuments.us/reader031/viewer/2022020218/559dce981a28ab54368b4821/html5/thumbnails/21.jpg)
www.crescosolution.com
Activity
This can happen either because the activity is finishing or because the system is temporarily destroying this instance of the activity to save space.
OnDestroy()
Called when you are no longer visible to the user.You will next receive either onRestart(), onDestroy(), or nothing, depending on later user activity.
OnStop()
Called when activity is in background ,but has not been killed.
OnPaused()
![Page 22: Advance Android application development workshop day 2](https://reader031.vdocuments.us/reader031/viewer/2022020218/559dce981a28ab54368b4821/html5/thumbnails/22.jpg)