Search code examples
androidxmlandroid-seekbarandroid-api-levels

Seekbar Styles not working on lower API's


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.sstatic.net/8CVfh.png

But it looks like this: https://i.sstatic.net/rmUa2.jpg


Solution

  • In Android, the designs, widgets even colors that are for higher API levels work/appear different in the lower API. You can't do anything to change that. If you want to use as you want then you have to choose the respective API levels.

    You can set the TargetSdkVersion always to the latest API version available. The minSdkVersion depends on which platform you want to support at least.