我需要将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>
问题在于它仅在api 21以上的设备中起作用。例如,在具有API 19 kitkat的设备中不起作用。
使其生效的唯一方法是在所有xml布局的android:theme="@style/SeekBar"
中的每个SeekBar中伪装此行,但这不是正确的方法。
如何解决这个问题?