android android layouts

9
Welcome Every Day is a new Beginning

Upload: perpetrotech

Post on 15-Jul-2015

205 views

Category:

Education


0 download

TRANSCRIPT

Page 1: Android android layouts

Welcome

Every Day is a new Beginning

Page 2: Android android layouts

Android – Layout Managers

•Android Layout Managers lays out the components on an Activity in a certain order / fashion

•Layout Managers manages the change in position & state of the components by itself

•There are many Layout managers available in Android. Let us take a look at few of them. The are as follows:

1. Absolute Layout

2. Relative Layout

3. Linear Layout

4. Table Layout

5. Tab Layout

6. List Layout

Page 3: Android android layouts

Absolute Layout

• Absolute Layout places the components in the position given by the user.

• Absolute Layout lets the user to mention the absolute positioning of each of the components.

• For each component, the developer needs to provide the x-coordinate (distance from left wall) and the y-coordinate (distance from the top) of the absolute position of the component

• This layout is easy to use compared to all other layouts.

• Since we mention the absolute positions, it becomes tedious to change the positioning of the components later in the development cycle

•A change in position of one of the components will alter the position of lot of other components in the same Activity

•Absolute Layout is deprecated as of the latest version of Android

Page 4: Android android layouts

Relative Layout

• Relative Layout places the components in the position given by the user.

• Absolute Layout lets the user to mention the relative positioning of each of the components.

• For each component, the developer needs to provide the x-coordinate of the distance from the nearest component and the y-coordinate of the distance from the nearest component of the absolute position of the component

• Relative Layout uses relative positioning of the components. Hence, any change in one of the component position will be handled by the Layout Manager itself

•A change in position of one of the components will alter the position of other components in the same Activity. The change will be automatically handled by the Layout Manager

• Since Absolute Layout is deprecated, the developers are recommended to use Relative Layout

Page 5: Android android layouts

Linear Layout

• Linear Layout places the components in a linear fashion

• Linear Layout allows the developer to use the ‘android:orientation’ property and positions the components in horizontal or vertical fashion

• <Linear Layout android:orientation = “horizontal” will position the components in linear horizontal fashion (in a single line or row)

• <Linear Layout android:orientation = “vertical” will position the components in vertical fashion (in a single column)

• Linear Layout is used and mixed with Relative Layout in order to achieve most of the designs in an Activity

Page 6: Android android layouts

Grid Layout

• Grid Layout places the components in multiple rows and columns (as in a matrix)

• Grid Layout lets the user to mention number of rows and columns in the Activity

• The number of rows and columns are fixed for the whole activity

• To achieve a table like structure, you can employ this Layout Manager

• Grid Layout is used to display the content in a MATRIX like structure (example : GALLERY application )

Page 7: Android android layouts

Table Layout

• Table Layout places the components in the rows and columns in an Activity

• Table Layout lets the user to mention the varying number of columns in each of the rows.

• Depending on the size and number of components, the Table Layout will arrange the components in a single row.

• Table Layout differs from the GridLayout in the sense that it allows varying number of columns in each of the rows

Page 8: Android android layouts

Tab Layout

• Tab Layout places multiple Activities in each of the tabs

• Tab Layout displays multiple activities in different tabs of the same screen space

• Each activity will be displayed in a separate tab so that multiple activities will share the same space but one Activity will overlap with another

• Only the chosen activity will be displayed at a single point of time

• Tab Layout is deprecated, as of the latest version

• Tab Layout can be used, if the developer wants to display similar Activities in adjacent screens

• Phone Dialler Application will also display Contact, Call Logs & Favorites section inside the same screen would be the best example

Page 9: Android android layouts

Thank You

Facebook.com/PerpetroTech

Office Address

New No 30/1Velachery Road, Little MountSaidapet, Chennai-15

Website: www.perpetrotech.comMail: [email protected]: +91- 8939707287