Seekbar Styles not working on lower API's

时间:2018-03-25 19:32:18

标签: android xml android-seekbar android-api-levels

I have a really weird issue, where i use the android:theme attribute, but it doesnt apply it for lower API versions.

This is my seekbar:

    <SeekBar
        android:id="@+id/amount"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_toEndOf="@id/subtract"
        android:layout_toStartOf="@+id/add"
        android:max="0"
        android:theme="@style/AppTheme.SeekBar3" /> 

This is the theme in question:

<style name="AppTheme.SeekBar3">
    <item name="colorPrimary">@color/colorBuyBlue</item>
    <item name="colorPrimaryDark">@color/colorBuyBlue</item>
    <item name="colorAccent">@color/colorBuyBlue</item>
</style>

It works on my emulator and on higher API phones but it doesn't work on API 21.

It should look like this: https://i.imgur.com/FdnHs2V.png

But it looks like this: https://i.imgur.com/ELnLsKn.jpg

1 个答案:

答案 0 :(得分:0)

在Android中,用于较高API级别的设计,小部件甚至颜色在较低的API中工作/显示不同。你无法做任何改变。如果您想根据需要使用,则必须选择相应的API级别。

您可以将TargetSdkVersion始终设置为可用的最新API版本。 minSdkVersion取决于您希望至少支持哪个平台。