Type of Layouts


The following list includes some of the more versatile layout classes available:

❑ FrameLayout The simplest of the Layout Managers, the Frame Layout simply pins each child
view to the top left corner. Adding multiple children stacks each new child on top of the previous,
with each new View obscuring the last.

❑ LinearLayout A Linear Layout adds each child View in a straight line, either vertically or horizontally.
A vertical layout has one child View per row, while a horizontal layout has a single row

of Views. The Linear Layout Manager allows you to specify a “weight” for each child View that
controls the relative size of each within the available space.

❑ RelativeLayout Using the Relative Layout, you can defi ne the positions of each of the child
Views relative to each other and the screen boundaries.

❑ TableLayout The Table Layout lets you lay out Views using a grid of rows and columns. Tables
can span multiple rows and columns, and columns can be set to shrink or grow.

❑ AbsoluteLayout In an Absolute Layout, each child View’s position is defi ned in absolute coordinates.
Using this class, you can guarantee the exact layout of your components, but at a price.

Compared to the previous managers, describing a layout in absolute terms means that your layout
can’t dynamically adjust for different screen resolutions and orientations.

Example :

<?xml version=”1.0” encoding=”utf-8”?>
<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”
android:orientation=”vertical”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”>
<TextView
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:text=”Enter Text Below”
/>
<EditText
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:text=”Text Goes Here!”
/>
</LinearLayout>




No comments:

IRCTC Share Price Declines by 2% Despite 30% Jump in Q4 Net Profit; Board Announces Dividend of INR 2 per Share

Introduction: The share price of Indian Railway Catering and Tourism Corporation (IRCTC) experienced a decline of 2% in today's trading ...