Seek bar, change path color from yellow to white
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!!!
How can i change the color of seekbar
Include this in seek bar:
<SeekBar
android:progressDrawable="@drawable/progress"
android:thumb="@drawable/thumb"/>
where 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>
and thumb.xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/thumb_fill" />
</selector>
Also you can refer this link - http://www.mokasocial.com/2011/02/create-a-custom-styled-ui-slider-seekbar-in-android/ and http://www.anddev.org/seekbar_progressbar_customizing-t6083.html
How to change seek bar progress colour according to its progress?
use custom seek bar for that requirement see following link's
http://www.mokasocial.com/2011/02/create-a-custom-styled-ui-slider-seekbar-in-android/
Seek bar, change path color from yellow to white
Changing color according to seek bar value
If you need only bright, saturated colors, use Color.HSVToColor()
instead of setting R, G and B components directly:
float[] hsvColor = {0, 1, 1};
// generate only hue component in range [0, 360),
// leaving saturation and brightness maximum possible
hsvColor[0] = 360f * progress / maxProgress;
view.setBackgroundColor(Color.HSVToColor(hsvColor));
This code will set color starting from red, then change smoothly to orange, yellow, green, blue and magenta back to red as progress
is changing from 0
to maxProgress
How to change the background of a SeekBar?
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
<?xml version="1.0" encoding="UTF-8"?>
<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>
and 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"
for more info see this link
How to change the background color of an ImageView using for example a SeekBar?
The suggestion from stkent has helped me.
Actually the answer in this post: android color between two colors, based on percentage? has helped me a lot.
In this case Mark Renouf`s solution was very helpful.
Thanks!
Custom seekbar (thumb size, color and background)
First at all, use
android:splitTrack="false"
for the transparency problem of your thumb.For the seekbar.png, you have to use a 9 patch. It would be good for the rounded border and the shadow of your image.
Related Topics
Getintent() Extras Always Null
List of Files in Assets Folder and Its Subfolders
How to Store SQLite Database Directly on Sdcard
Android Exception: Did You Forget to Call 'Public Void Setup (Localactivitymanager Activitygroup)'
Error:Cause: Unable to Find Valid Certification Path to Requested Target
Android: Open Activity Without Save into the Stack
How to Create Android Spinner Without Down Triangle on the Right Side of the Widget
Android:Fill Spinner from Java Code Programmatically
Android: Webview Inside Dialog or Popup
Android: How to Use Webcam in Emulator
Load an Image from Assets Folder
Using Listview:How to Add a Header View
How to Implement a Setonitemclicklistener Firebaserecyclerviewadapter
Importing Module in Android Studio
Hide Ics Back Home Task Switcher Buttons
Sqlite Returned an Error Code of 14
Android Edittext Onchange Listener
How to Get the Current Location in Google Maps Android API V2