Tuesday, 28 June 2011

Layout Manager Basics

Handy android-layout-tutorial

LinearLayout = Stuff in a line 1 after the other.

FrameLayout = Designed for displaying 1 item at a time. Putting 2 items in will stack them one over the other

TableLayout = Grid Table Layout

Gravity:
This centers the item according to its parent:
android:layout_gravity="center_horizontal|center_vertical"

This centers what is inside the item. If you want to center text on a button use this:
android:gravity="center_horizontal|center_vertical"


Add to a Layout if you need stuff at the bottom of the screen:
android:layout_height="fill_parent"
android:gravity="bottom"


Fill the rest of the space with this item:
android:layout_weight="1"

10 spaces inside. eg: 10 pixels from button edge to text on button.
android:padding="10"

5 spaces outside. eg: 5 pixels between this button and the next button
android:layout_margin="5"

No comments:

Post a comment