Android 按钮栏 - buttonBarButtonStyle 在按钮之间留下间隙 [英] Android Button Bar - buttonBarButtonStyle leaves gap between buttons

查看:36
本文介绍了Android 按钮栏 - buttonBarButtonStyle 在按钮之间留下间隙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用内置的 Android 按钮栏样式时遇到了一些问题.在为我的每个按钮指定宽度为 0 和重量为 1 之后,两个按钮之间仍然有大约 1px 的间隙(见图).

I'm having some trouble with the built in Android button bar styling. After giving a width of 0 and weight of 1 to each of my buttons, there's still about a 1px gap in between the two buttons (see image).

消除这种差距的最佳方法是什么?为什么一开始就在那里?

What is the best way to get rid of that gap? Why is it even there to begin with?

<LinearLayout
    android:id="@+id/button_bar"
    style="?android:attr/buttonBarStyle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignRight="@+id/details_scroll_view"
    android:paddin="0dp" >

    <Button
        android:id="@+id/button1"
        style="?android:attr/buttonBarButtonStyle"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="@drawable/button_dark_blue"
        android:text="button1"
        android:textColor="@color/text_color" />

    <Button
        android:id="@+id/button2"
        style="?android:attr/buttonBarButtonStyle"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="@drawable/button_light_blue"
        android:text="button2"
        android:textColor="@color/text_color" />
</LinearLayout>

[按钮栏][1]http://i.stack.imgur.com/9Kwf4.png

推荐答案

如果你使用 RelativeLayout 而不是 LinearLayout 那么你可以使用类似

If you use a RelativeLayout instead of LinearLayout then you can use something like

 <Button
        android:id="@+id/button2"
        style="?android:attr/buttonBarButtonStyle"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="@drawable/button_light_blue"
        android:text="button2"
        android:textColor="@color/text_color"
        android:layout_toRightOf="@+id/button1" />  //this will put the left edge of this button at the right edge of button1

这篇关于Android 按钮栏 - buttonBarButtonStyle 在按钮之间留下间隙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆