Android 为什么我的可绘制按钮布局没有作为背景应用于按钮?

Android 为什么我的可绘制按钮布局没有作为背景应用于按钮?,android,xml,button,layout,Android,Xml,Button,Layout,我创建了一个buttonbg.xml文件,为按钮提供一个带有自定义颜色的圆形。 下面是xml代码的样子 <stroke android:color="#69B9F9" android:width="3dp" /> <corners android:radius="200dp" /> 但当我将此xml作为按钮的背景应用时 <Button android:id="@+i

我创建了一个buttonbg.xml文件,为按钮提供一个带有自定义颜色的圆形。 下面是xml代码的样子

<stroke
    android:color="#69B9F9"
    android:width="3dp" />

<corners
    android:radius="200dp" />

但当我将此xml作为按钮的背景应用时

<Button android:id="@+id/loginButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentStart="true"
    android:layout_alignParentEnd="true"
    android:layout_alignParentBottom="true"
    android:layout_marginStart="59dp"
    android:layout_marginEnd="61dp"
    android:layout_marginBottom="227dp"
    android:background="@drawable/button_bg"
    android:text="LOGIN"
    android:textSize="22sp" />

什么都没发生


请帮帮我

将此添加到您的按钮

app:backgroundTint="@null" 
在你的问题中你也写了

我已经创建了一个buttonbg.xml文件


在代码中,您已经编写了button_bg.xml。请检查您的代码中是否存在输入错误,或者问题本身是否存在输入错误

您可以将按钮包装为可绘制,并将该可绘制应用于线性布局或任何其他布局。因此,基本上创建自定义按钮这是实现自定义按钮的一种非常简单的方法。

这里有一个提示,用于您不想使用
app:backgroundTint的时候=“@null
每次您要向按钮添加背景时。转到您的themes.xml文件。在第一个样式标记中,您将看到

<style name="Theme.[AppName]" parent="Theme.MaterialComponents...."

谢谢,成功了!