android.support.v7.widget.AppCompatButton 无法实例化(使用自定义样式)

android.support.v7.widget.AppCompatButton could not be instantiated (using custom style)

这并不能通过简单地将 Theme.AppCompat.Light.DarkActionBar 更改为 Base 来解决。Theme.AppCompat.Light.DarkActionBar

我正在尝试使用自定义按钮样式,但收到以下错误:

无法实例化以下 类:

android.support.v7.widget.AppCompatButton

这并不能通过简单地将 Theme.AppCompat.Light.DarkActionBar 更改为 Base 来解决。Theme.AppCompat.Light.DarkActionBar

我使用的是自定义样式,所以这很可能与此无关。

这是我当前的代码:

Styles.XML

<!-- Base application theme. -->
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="RaisedButton" parent="Widget.AppCompat.Button.Colored">

    <item name="backgroundTint">@color/colorButton</item>
    <item name="android:textColor">@color/colorButtonText</item>


</style>

activity_patient_main.xml

<android.support.v7.widget.AppCompatButton
    android:id="@+id/button3"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:text="@string/ask_a_question"
    android:layout_marginTop="20dp"
    android:layout_marginBottom="20dp"
    android:theme="@style/RaisedButton"
    android:onClick="buttonClicked"
    android:textSize="60sp" />

我尝试过的事情:

正在将 Theme.AppCompat.Light.DarkActionBar 更改为基础。Theme.AppCompat.Light.DarkActionBar,

清除缓存并重新启动

正在将我的 Gradle 版本更改为 28.0.0-alpha1

Widget.AppCompat.Button.Colored 变为 Base.Widget.AppCompat.Button.Colored

正在检查我是否正在延长 AppCompatActivity (我是)

请注意,它在我的 phone 上 运行,但不会在 android 工作室中渲染。我不知道这是否只是渲染器的问题,如果是,问题是否可以解决?

感谢您的协助!

你应该使用

<item name="android:backgroundTint">@color/colorButton</item>

而不是

<item name="backgroundTint">@color/colorButton</item>

注意,它需要 API 21 级!