Seek bar, change path color from yellow to white

AndroidAndroid Emulator

Android Problem Overview


I have two questions:

  1. how do I change the color of the seek bar (path) from yellow (the default color) to white. What I mean to say is, while I slide the thumb , it turns the line traversed from grey to yellow. I want track/line to either remain grey or white..Basically I want just the thumb to move with no color change in the seek bar.

How to change the thumb of seekbar from rectangle to circle/sphere/round shape.

any pointers will be appreciated.

Android Solutions


Solution 1 - Android

I want to complete the answer from above for the people who are new to the system,

the missing xmls ( background_fill , progress_fill and progress could look like that for a gradient red

progress.xml

<?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
        <item 
            android:id="@android:id/background" 
            android:drawable="@drawable/background_fill" />

        <item android:id="@android:id/progress">
           <clip android:drawable="@drawable/progress_fill" />
        </item>
  </layer-list>

background_fill.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient 
        android:startColor="#FF555555" 
        android:centerColor="#FF555555"
	    android:endColor="#FF555555" 
        android:angle="90" />

    <corners android:radius="5px" />

    <stroke 
        android:width="2dp" 
        android:color="#50999999" />

    <stroke 
        android:width="1dp" 
        android:color="#70555555" />
</shape>

progress_fill.xml

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient 
        android:startColor="#FF470000" 
        android:centerColor="#FFB80000"
	    android:endColor="#FFFF4400" 
        android:angle="180" />

    <corners android:radius="5px" />

	<stroke 
            android:width="2dp" 
            android:color="#50999999" />
    
	<stroke 
            android:width="1dp" 
            android:color="#70555555" />
</shape>

i did not complete the implementing for android:thumb, so the thumb will be still the original one

Therefore we just have to delete this line again from our layout xml where we define the seekbar

android:thumb="@drawable/thumb"

Good luck!!!

Solution 2 - Android

You should set SeekBar XML properties:

<SeekBar 
            ....
	android:progressDrawable="@drawable/progress"
	android:thumb="@drawable/thumb"
            ....
/>

Where progress is something like this:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background" 
	android:drawable="@drawable/background_fill" />

<item android:id="@android:id/progress">
	<clip android:drawable="@drawable/progress_fill" />
</item>
</layer-list> 

and thumb is

<?xml version="1.0" encoding="utf-8"?>    
<selector xmlns:android="http://schemas.android.com/apk/res/android">
   <item android:drawable="@drawable/thumb_fill" />
</selector>

Solution 3 - Android

Since SeekBar uses colorAccent by default, you can create a new style with your custom color as colorAccent then use theme attribute to apply it to the SeekBar.

<SeekBar>
    .
    .
    android:theme="@style/MySeekBarTheme"
    .
</SeekBar>

in the @style:

 <style name="MySeekBarTheme" parent="Widget.AppCompat.SeekBar" >
        <item name="colorAccent">#ffff00</item>
 </style>

Solution 4 - Android

seekBar.getProgressDrawable().setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);
seekBar.getThumb().setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);

Solution 5 - Android

You can just add tint from API level 21.

Add these properties to seekbar element:

> android:progressTint="@android:color/white" > android:thumbTint="@android:color/white"

Final result:

<SeekBar
	android:id="@+id/is"
	android:layout_width="match_parent"
	android:max="100"
	android:progressTint="@android:color/white"
	android:thumbTint="@android:color/white"/>

Solution 6 - Android

1. Create a drawable XML: Name it : progress_drawable

> >
> http://schemas.android.com/apk/res/android" > android:shape="line"> >
> >
>

2. Assign it to Seekbar

            <SeekBar
                    android:id="@+id/slider_1"
                    android:progressDrawable="@drawable/progress_drawable"
                    android:layout_width="180dp"
                    android:layout_height="32dp"
                    android:layout_gravity="center"
                    android:rotation="270" />

Solution 7 - Android

Just change the accent color of your style

<style name="TickMarkSeekBar" parent="Theme.KefTheme">
        <item name="tickMark">@drawable/tickmark</item>
        <item name="thumbTint">@android:color/white</item>
        <item name="colorAccent">@android:color/white</item>
    </style>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDavid PrunView Question on Stackoverflow
Solution 1 - AndroidThe Digital Ad VentureView Answer on Stackoverflow
Solution 2 - AndroidAsahiView Answer on Stackoverflow
Solution 3 - AndroidhedisamView Answer on Stackoverflow
Solution 4 - AndroidAlireza GhanbariniaView Answer on Stackoverflow
Solution 5 - AndroidquentView Answer on Stackoverflow
Solution 6 - AndroidAbhishek SenguptaView Answer on Stackoverflow
Solution 7 - AndroidRexSplodeView Answer on Stackoverflow