删除Android按钮的边距

删除Android按钮的边距,android,android-layout,user-interface,android-theme,Android,Android Layout,User Interface,Android Theme,如何删除Android按钮使用的默认边距?我希望按钮具有全宽(屏幕边缘和按钮之间没有任何空间)并且它们之间没有空间。我没有设置任何填充,但他们似乎有一个 我正在使用“Theme.AppCompat.Light.NoActionBar”作为我的应用程序主题父级 <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientatio

如何删除Android按钮使用的默认边距?我希望按钮具有全宽(屏幕边缘和按钮之间没有任何空间)并且它们之间没有空间。我没有设置任何填充,但他们似乎有一个

我正在使用“Theme.AppCompat.Light.NoActionBar”作为我的应用程序主题父级

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</LinearLayout>


在按钮xml中按如下所示使用,然后将其他功能更改为您希望的显示方式

style="?android:attr/buttonBarButtonStyle"

在按钮xml中使用如下所示,然后将其他功能更改为您希望它们的显示方式

style="?android:attr/buttonBarButtonStyle"
你可以用 android:minHeight=0 android:minWidth=0以删除按钮上的额外边框。

您可以使用 android:minHeight=0
android:minWidth=0以删除按钮的额外边框。

我也遇到了同样的问题。默认按钮带有边距。设置按钮属性,如下所示:

android:layout_marginTop="-3dp"
对左、右和下页边距执行相同的操作。或使用以下参数定义新的可绘制图形:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle"
    android:padding="10dp"
    >
    <solid android:color="@color/colorButtonGray"/>
    <corners
        android:bottomRightRadius="2dp"
        android:bottomLeftRadius="2dp"
        android:topLeftRadius="2dp"
        android:topRightRadius="2dp"/>
</shape> 


自定义形状将没有任何内置边距。

我也有同样的问题。默认按钮带有边距。设置按钮属性,如下所示:

android:layout_marginTop="-3dp"
对左、右和下页边距执行相同的操作。或使用以下参数定义新的可绘制图形:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle"
    android:padding="10dp"
    >
    <solid android:color="@color/colorButtonGray"/>
    <corners
        android:bottomRightRadius="2dp"
        android:bottomLeftRadius="2dp"
        android:topLeftRadius="2dp"
        android:topRightRadius="2dp"/>
</shape> 


自定义形状将没有任何内置边距。

这很可能是来自按钮背景。您是否使用了提供的解决方案之一?尝试过,但没有按照我的要求工作。最后,我在这里使用了自定义涟漪效果作为背景:很可能是来自按钮背景。您是否使用了提供的解决方案之一?尝试过,但没有按照我的要求工作。最后,我在这里使用了一个自定义涟漪效果作为背景:用于删除填充,而不是边距。用于删除填充,而不是边距。