Sunday, May 9, 2010

Android – Simple Layout creation method

You can create such layouts easily as a first step towards developing android apps, by using Eclipse IDE with the SDK.
image
XML File / Code associated with the above Layout
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" >
     <LinearLayout
    android:id="@+id/LinearLayout02"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent"
    android:background="#3D3D3D"
    android:layout_weight="4">
        <TextView
        android:text="Header"
        android:textSize="15pt"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_weight="1"></TextView>
    </LinearLayout>
    <LinearLayout
    android:id="@+id/LinearLayout03"
    android:layout_height="fill_parent"
    android:background="#ffffff"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_weight="1">
    <TextView
    android:text="red"
    android:id="@+id/TextView01"
    android:layout_width="wrap_conent"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:gravity="center_horizontal" android:background="#aa0000"></TextView>
    <TextView
    android:text="blue"
    android:id="@+id/TextView01"
    android:layout_width="wrap_conent"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:gravity="center_horizontal" android:background="#0000aa"></TextView>
    <TextView
    android:text="green"
    android:id="@+id/TextView01"
    android:layout_width="wrap_conent"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:gravity="center_horizontal" android:background="#00aa00"></TextView>
    </LinearLayout>
    <LinearLayout
    android:id="@+id/LinearLayout04"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent"
    android:background="#3D3D3D"
    android:layout_weight="4">
        <TextView
        android:text="Footer"
        android:textSize="15pt"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_weight="1"></TextView>
    </LinearLayout>
</LinearLayout>
-----
You should also be able to find more examples on http://developer.android.com

No comments:

Post a Comment