【发布时间】:2019-12-21 07:16:42
【问题描述】:
我正在尝试在 XML 中创建一个胶囊/药丸形状的按钮。我已经定义了一个drawable并将其设置为我的按钮的背景,但是在预览中,当我运行应用程序时,它显示为一个蓝色矩形,尽管背景drawable是一个白色的椭圆形。有谁知道为什么会发生这种情况?
这是按钮:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/search_box"
android:layout_centerHorizontal="true"
android:layout_marginTop="24dp"
android:background="@drawable/button_capsule"
android:text="@string/search"
android:textColor="@color/precipLightBlue"/>
这是背景可绘制对象:
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="1000dp" />
<solid android:color="@android:color/white" />
</shape>
【问题讨论】:
-
您可以添加图片吗?这样我们就可以了解其中的实际问题是什么
标签: android android-layout material-design android-button material-components-android