-1

I am wondering how it's possible to create a buttom bar buttons in android, can any thing to set bottom bar in Linear Layout ?

main.xml is :

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

        <TextView android:text="@string/hello" android:layout_width="wrap_content"
        android:layout_gravity="center_horizontal" android:layout_height="wrap_content"
        android:layout_marginTop="30dip" />
        <TextView android:layout_width="wrap_content" android:id="@+id/small_text"
        android:layout_height="wrap_content" android:text="@string/small_text"
        android:layout_gravity="center" android:layout_margin="40dip"></TextView>
        <TextView android:layout_width="wrap_content" android:id="@+id/normal_text"
        android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium"
        android:layout_margin="10dip" android:text="@string/normal_text"
        android:layout_gravity="center"></TextView>
        <TextView android:layout_width="wrap_content" android:id="@+id/large_text"
        android:editable="true" android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:layout_margin="10dip" android:text="@string/large_text"
        android:layout_gravity="center" android:focusable="false"
        android:focusableInTouchMode="false"></TextView>

        <LinearLayout android:id="@+id/footer"
        android:layout_width="fill_parent" android:orientation="horizontal"
        android:layout_alignParentBottom="true" style="@android:style/ButtonBar"
        android:layout_height="wrap_content" android:layout_gravity="bottom">

            <Button android:id="@+id/saveButton" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:layout_weight="1"
                android:text="Start" />

            <Button android:id="@+id/cancelButton" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:layout_weight="1"
            android:text="Exit" />
        </LinearLayout>
</LinearLayout>
Rahul Mandaliya
  • 738
  • 1
  • 12
  • 36
  • check this link http://stackoverflow.com/questions/5467516/android-bottom-button-bar-in-prefernceactivity he is asking about the same thing. – Khaled Annajar May 02 '13 at 14:34

1 Answers1

0

replace your footer layout tag from LinearLayout to RelativeLayout as you have set the attributes of RelativeLayout there like this:

<RelativeLayout android:id="@+id/footer"
        android:layout_width="fill_parent" android:orientation="horizontal"
        android:layout_alignParentBottom="true" style="@android:style/ButtonBar"
        android:layout_height="wrap_content" android:layout_gravity="bottom">

            <Button android:id="@+id/saveButton" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:layout_weight="1"
                android:text="Start" />

            <Button android:id="@+id/cancelButton" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:layout_weight="1"
            android:text="Exit" android:layout_below="@+id/saveButton" />
        </RelativeLayout >
Vineet Shukla
  • 23,865
  • 10
  • 55
  • 63
  • use android:orientation="vertical" and remove android:layout_alignParentBottom="true" and android:layout_gravity="bottom" and use android:gravity="bottom" ... – Vineet Shukla Aug 16 '11 at 07:34