A layout manager is a subclass of
As of Android 4.0 the most relevant layout manager are
All layouts allow the developer to define attributes. Children can also define attributes which may be evaluated by their parent layout.
ViewGroup and is responsible for the layout of itself and its child Views. Android supports different default layout managers.As of Android 4.0 the most relevant layout manager are
LinearLayout, FrameLayout, RelativeLayout and GridLayout.All layouts allow the developer to define attributes. Children can also define attributes which may be evaluated by their parent layout.
AbsoluteLayoutLayout is deprecated and TableLayout can be implemented more effectively via GridLayoutLinearLayout puts all its child elements into a single column or row depending on the android:orientation attribute. Possible values for this attribute are horizontal and vertical, horizontal is the default value.LinearLayout can be nested to achieve more complex layouts.RelativeLayout allow to position the widget relative to each other. This allows for complex layouts.A simple usage for
RelativeLayout is if you want to center a single component. Just add one component to the RelativeLayout and set the android:layout_centerInParent attribute to true.<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <ProgressBar android:id="@+id/progressBar1" style="?android:attr/progressBarStyleLarge" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" /> </RelativeLayout>
GridLayout
was introduced with Android 4.0. This layout allows you to organize a
view into a Grid. GridLayout separates its drawing area into: rows,
columns, and cells.You can specify how many columns you want for define for each
View in which row and column it should be placed and how many columns and rows it should use. If not specified GridLayout uses defaults, e.g. one column, one row and the position of a View depends on the order of the declaration of the Views.
No comments:
Post a Comment