如何在API 21以上的所有SeekBar应用样式?

问题描述 投票:0回答:1

我需要将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布局的每个SeekBar中伪装此行:android:theme="@style/SeekBar",但这不是正确的方法。

如何解决此问题?

android android-layout styles android-styles android-seekbar
1个回答
0
投票
dependencies { compile "com.android.support:appcompat-v7:21.0.+" }

您可以在this博客文章中了解更多信息>

© www.soinside.com 2019 - 2024. All rights reserved.