添加背景颜色时的Android按钮边距

时间:2015-04-04 12:16:29

标签: android xml button android-studio

当我更改按钮的背景颜色时,我的按钮边距(Android Studio)有问题。所有按钮大小相同,但添加背景颜色的按钮之间没有空格。我该如何解决这个问题?

No spaces between buttons with added background color

此代码适用于未着色按钮的按钮

<Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/btnAdd"
        android:id="@+id/btnAdd"
        android:layout_above="@+id/btnSub"
        android:layout_centerHorizontal="true"/>

我添加了这一行以获得彩色按钮的背景颜色。

android:background="@color/red"

如果我从中间按钮中删除所有背景属性,则所有按钮看起来都相同且同步。

Buttons without background color

这些是没有这行代码的相同按钮:

android:background="@color/red"

如何使用相同的边距和背景颜色获得完全相同的按钮尺寸?没有涉及的Java代码。只需上面的xml代码。

0 个答案:

没有答案
相关问题