View

Tuesday, 12 April 2011

Center Alignment Button


This Sample XML code to show the Buttons present in the center of the Emulator,just try it.



<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">



<TextView
android:id="@+id/textView1"
  android:layout_width="fill_parent"
android:layout_height="wrap_content"
  android:layout_alignParentLeft="true"
android:gravity="center"
android:textSize="22dip"
android:background="#008000"
android:typeface="serif"
  android:text="Main Menu">
</TextView>


<Button
  android:layout_width="200dp"
android:textSize="10dp"
android:layout_height="30dp"
android:paddingLeft="35dp"
android:paddingRight="35dp"
android:text="New Greeting"
android:id="@+id/button1"
android:maxHeight="10dp"
android:layout_below="@+id/textView1">

</Button>

<Button
  android:layout_below="@+id/button1"
  android:textSize="10dp"
android:layout_width="200dp"
android:layout_height="30dp"
android:text="My Greeting"
  android:id="@+id/button2"
android:layout_alignLeft="@+id/button1"
android:layout_alignRight="@+id/button1">
</Button>


<Button android:layout_below="@+id/button2"
android:textSize="10dp"
android:layout_width="200dp"
  android:layout_height="30dp"
android:text="My Gift"
  android:id="@+id/button3"
android:layout_alignLeft="@+id/button2"
android:layout_alignRight="@+id/button2">
</Button>



<Button
android:layout_below="@+id/button3"
android:layout_width="200dp
  android:layout_height="30dp"
android:text="Pending Greeting"
  android:id="@+id/button4"
android:textSize="10dp"
android:layout_alignLeft="@+id/button3">
</Button>

<Button
android:layout_below="@+id/button4"
android:layout_width="200dp"
  android:layout_height="30dp"
android:text="Greeting Calendar"
android:id="@+id/button5"
android:textSize="10dp"
android:layout_alignRight="@+id/button4">
</Button>

</RelativeLayout>





No comments:

Post a Comment