Android AppCompatButton和buttonStyle

Android AppCompatButton和buttonStyle,android,android-appcompat,android-theme,Android,Android Appcompat,Android Theme,我正在尝试使用AppCompat库为Android 4.4设备提供一些使用材质设计风格(特别是accentColor着色)的按钮。我在以下方面取得了成功: <android.support.v7.widget.AppCompatButton android:layout_width="match_parent" android:layout_height="wrap_content" android:t

我正在尝试使用AppCompat库为Android 4.4设备提供一些使用材质设计风格(特别是accentColor着色)的按钮。我在以下方面取得了成功:

        <android.support.v7.widget.AppCompatButton
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/continue_button"
            android:id="@+id/continue_button"
            android:layout_gravity="center_horizontal|bottom"
            style="@style/CompatButton"
            android:theme="@style/ThemeOverlay.AppCompat.Dark"/>

其中“@style/CompatButton”具有“Widget.AppCompat.Button.Colored”作为父项。但是,我的一些按钮是相同的,但我没有在元素中声明样式,而是将样式附加为正在使用的主题中的默认“buttonStyle”:

<style name="AppTheme">
    ...
    <item name="android:buttonStyle">@style/CompatButton</item>
    <item name="colorAccent">@color/flow_accent</item>
    ...
</style>

...
@样式/兼容性按钮
@颜色/流/重音
...



这些按钮显示为默认的非材质样式。ProgressBar似乎也是如此。有人能看出这有什么问题吗?如果没有明确定义按钮样式的解决方法,那就太傻了。显然,ThemeOverlay删除了前面的主题,包括buttonStyle定义。要使其正常工作,我们必须重新添加按钮样式:

    <style name="FlowOverlay" parent="ThemeOverlay.AppCompat.Dark">
        <item name="android:buttonStyle">@style/CompatButton</item>
    </style>

        <android.support.v7.widget.AppCompatButton
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/continue_button"
            android:id="@+id/continue_button"
            android:layout_gravity="center_horizontal|bottom"
            android:theme="@style/FlowOverlay"/>

@样式/兼容性按钮

尽管这首先会失去默认按钮样式所带来的许多便利。

在使用AppCompat小部件时,使用
按钮样式
,而不是
android:buttonStyle
(等等)。
    <style name="FlowOverlay" parent="ThemeOverlay.AppCompat.Dark">
        <item name="android:buttonStyle">@style/CompatButton</item>
    </style>

        <android.support.v7.widget.AppCompatButton
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/continue_button"
            android:id="@+id/continue_button"
            android:layout_gravity="center_horizontal|bottom"
            android:theme="@style/FlowOverlay"/>