Android SeekBar's progressBackgroundTint has no effect in API v21
Asked Answered
C

3

8

I'm noticing that when changing my SeekBar's progressBackgroundTint attribute, it gets completely ignored and has no effect. It doesn't matter what color I set it to; it always shows as gray on my device. Is this a bug with Android, or am I doing something wrong? When I switch the preview in Android Studio to v22, it gets properly set. But not so on v21.

My seekbar:

<SeekBar
    android:layout_width="300dp"
    android:layout_height="wrap_content"
    android:id="@+id/seekBar"
    android:max="100"
    android:progress="50"
    android:progressBackgroundTint="#ff4babe8"/>

I also tried setting progressBackgroundTintMode to all the known values, but still no effect. Anyone know why?

Charters answered 2/11, 2015 at 20:40 Comment(3)
Your hex color has 2 too many characters... 8 instead of 6.Exultant
@MikePurcell: The first hex byte (FF) is the alpha value. See e.g. android.graphics.Color. So problem is not there.Disappoint
May be it only work for device with OS lollipop or greaterExpend
G
2

Try this library. It works great simple https://github.com/ahmedrizwan/SeekBarCompat

Galenic answered 2/11, 2015 at 23:50 Comment(0)
F
0

try using android:progressTint along with android:progressBackgroundTint

<ProgressBar
     android:progress="100"
     android:progressBackgroundTint="@color/buttonPrimary"
     android:progressTint="@color/buttonPrimary"
     android:id="@+id/progressBar"
     style="?android:attr/progressBarStyleHorizontal"
     android:layout_width="match_parent"
     android:layout_height="wrap_content" />
Fabrizio answered 9/5, 2020 at 9:23 Comment(1)
It is still not workingBromism
E
0

I just discovered this issue and then found out that the material components provide a Slider that works pretty much the same way and doesn't have this issue. Check out details here https://developer.android.com/reference/com/google/android/material/slider/Slider

Earn answered 24/6, 2022 at 17:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.