3

Im trying to change the color of a AppCompatSeekBar on a android project im working on.

This is the code im using for it

<android.support.v7.widget.AppCompatSeekBar
            android:id="@+id/seekbar"
            android:progressTint="@android:color/white"
            android:layout_width="match_parent"
            android:layout_centerInParent="true"
            android:paddingLeft="@dimen/activity_horizontal_margin"
            android:paddingRight="@dimen/activity_horizontal_margin"
            android:layout_height="50dp"
            android:thumb="@drawable/closeprogress"
            />

and it looks like this

enter image description here

what i want is to change the color of the right part of seekbar ( after the baloon) to something like blue. Right now i can only change the "filled" portion of the bar to white.

Thought
  • 5,326
  • 7
  • 33
  • 69

3 Answers3

4

If your app's api level >= 21, you can use

android:progressBackgroundTint="#0000ff"(blue color)

As I see you use android:progressTint="@android:color/white"

else Set SeekBar XML properties

Smiles
  • 481
  • 1
  • 6
  • 15
1

In AppCompat themes Seekbar takes accentColor of your app so you could simply change it to whatever you want in values/color/accentColor. set to to whatever color you want.

halfer
  • 19,824
  • 17
  • 99
  • 186
Atiq
  • 14,435
  • 6
  • 54
  • 69
0

you can use styles to add a gradient. But it's realldy hard to change the gradient after the user changed the position of the baloon. If you don't want to change the gradient after the baloon position has changed, it would be no problem to add a style with an gradient.

Ben
  • 696
  • 9
  • 19
  • What i want is to have the bar on the right of the balloon blue and on left white, regardless of the baloon position ( left side, middle or right ), not sure i can do that with a gradient. For example if baloon was on starting position (left) bar would be all blue, – Thought May 03 '16 at 14:32
  • you are confusing me. You say you want to color the bar unrelated to the baloon but in the next sentence you say, if the baloon is on start position the bar should be totally blue. Anyway, I think you have to create this programmatically and not with xml styles. Maybe this link could help you: http://stackoverflow.com/questions/12427025/android-gradient-drawable-programmatically – Ben May 03 '16 at 14:39
  • everything left of baloon is white, everything right of baloon is blue, and the baloon can move – Thought May 03 '16 at 14:54
  • yah I know what you mean. As I meantioned, do this programmatically would be probably the best way. – Ben May 03 '16 at 14:57
  • can you give a example? – Thought May 03 '16 at 14:58
  • I posted a link above – Ben May 03 '16 at 15:04