XML按钮背景色不变

XML按钮背景色不变,xml,android-studio,Xml,Android Studio,我有一个XML标记: <Button android:id="@+id/next" android:layout_width="305dp" android:layout_height="64dp" android:background="@color/colorTheme" style="@style/ButtonSty

我有一个XML标记:

<Button
        android:id="@+id/next"
        android:layout_width="305dp"
        android:layout_height="64dp"
        android:background="@color/colorTheme"
        style="@style/ButtonStyle"
        android:text="Next"
        app:layout_constraintBottom_toTopOf="@+id/imageViewFooterGetStarted"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.968" />

由于某种原因,我的按钮的背景色没有改变。我已尝试仅使用style.xml:

<style name="ButtonStyle" parent="android:Widget.Button">
        <item name="android:background">@drawable/btn_get_started</item>
        <item name="android:textColor">@color/colorTheme</item>
    </style>

@可绘制/btn\u开始
@颜色/颜色主题
并且仍然具有默认的紫色
android:background
也没有任何效果。 是什么导致背景颜色不改变


编辑:我找到了解决方案。结果显示,
android:background
会更改颜色,但仅当使用了
标记而不是
标记时,才可以尝试使用AppCompatButtom而不是Button

用AppCompatButtom替换您的按钮

 <androidx.appcompat.widget.AppCompatButton
            android:id="@+id/next"
            android:layout_width="305dp"
            android:layout_height="64dp"
            android:background="@color/colorTheme"
            style="@style/ButtonStyle"
            android:text="Next"
            app:layout_constraintBottom_toTopOf="@+id/imageViewFooterGetStarted"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="0.968" />

希望它的工作