简体   繁体   中英

making bottom bar in android

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

在此输入图像描述

My output is like below image

在此输入图像描述

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?

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.

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM