Anoo
Anoo

Reputation: 113

making bottom bar in android

I am trying to make bottom bar that should look like below image. i.e., they should be separate only with line exactly like below image.

enter image description here

My output is like below image

enter image description here

My code:

<LinearLayout
        android:id="@+id/buttonbar"
        style="@android:style/ButtonBar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/okButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@android:string/ok" />

        <Button
            android:id="@+id/cancelButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@android:string/cancel"  />
    </LinearLayout>

I have imported an example and it's looking like the first image. But when I used the same code in my project and tested on the same emulator, it's looking like the second one. Can some one suggest what should be done to look like in the first image?

Upvotes: 0

Views: 5989

Answers (2)

kathir
kathir

Reputation: 489

Try this code, it will give a result like the first image. But I did some color changes only.

Code:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/buttonbar"
    style="@android:style/ButtonBar"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:background="#000000"
    android:orientation="horizontal" >

        <Button
            android:id="@+id/okButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#000000"
            android:layout_weight="1"
            android:text="@android:string/ok"
            android:textColor="#FFFFFF" />

        <Button
            android:id="@+id/cancelButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#000000"
            android:layout_weight="1"
            android:text="@android:string/cancel"
            android:textColor="#FFFFFF" />

    </LinearLayout>

Update: This is what you need.

Edited:

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/buttonbar"
        style="@android:style/ButtonBar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#000000"
        android:orientation="horizontal" >

            <Button
                android:id="@+id/okButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="#000000"
                android:layout_weight="1"
                android:text="@android:string/ok"
                android:textColor="#FFFFFF" />

            <View
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:background="#ffffff" />

            <Button
                android:id="@+id/cancelButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="#000000"
                android:layout_weight="1"
                android:text="@android:string/cancel"
                android:textColor="#FFFFFF" />

        </LinearLayout>

Increase the size of dp as much as you want to show the difference.

Upvotes: 2

saa
saa

Reputation: 1568

try this..

        <Button
            android:id="@+id/okButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@android:string/ok"
style="?android:attr/borderlessButtonStyle" />

        <Button
            android:id="@+id/cancelButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@android:string/cancel"
style="?android:attr/borderlessButtonStyle"  />
    </LinearLayout>

Upvotes: 0

Related Questions