Android 如何将样式应用于API 21以下和以上的所有Seekbar?

Android 如何将样式应用于API 21以下和以上的所有Seekbar?,android,android-layout,styles,android-styles,android-seekbar,Android,Android Layout,Styles,Android Styles,Android Seekbar,我需要将styles.xml中的样式应用于xml布局中的所有SeekBar视图,因此我尝试了以下方法: <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <item name="seekBarStyle">@style/SeekBar</item> </style> <style name=

我需要将styles.xml中的样式应用于xml布局中的所有SeekBar视图,因此我尝试了以下方法:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="seekBarStyle">@style/SeekBar</item>
</style>

<style name="SeekBar" parent="@style/Widget.AppCompat.SeekBar">
    <item name="colorAccent">@color/button_color</item> <!-- below api 21 it's necessary this line and to add this style with android:theme in the layout xml file -->

    <item name="android:progressBackgroundTint">@color/button_color</item>
    <item name="android:thumbTint">@color/button_color</item>
    <item name="android:thumbTintMode">src_in</item>
    <item name="android:progressTint">@color/button_color</item>
</style>

@样式/搜索栏
@颜色/按钮颜色
@颜色/按钮颜色
@颜色/按钮颜色
src_in
@颜色/按钮颜色
问题是它只在api 21以上的设备中工作。例如,在带有API 19的设备中,Kitkat不起作用

唯一可行的方法是在所有XML布局中的每个SeekBar中使用这一行:
android:theme=“@style/SeekBar”
,这不是正确的方法


如何解决此问题?

AFAIK材质主题属性(如android:colorAccent、android:colorPrimary或android:colorPrimaryDark等)旨在与android 21配合使用,如果您想在21之前使用API级别的属性, 您添加了
@color/my\u awesome\u color
values/themes.xml
中,添加AppCompact依赖项后,在
build.gradle

dependencies {
    compile "com.android.support:appcompat-v7:21.0.+"
}
你可以在博客上看到更多关于这方面的信息