Reputation: 5431
I need a seek bar which color need this
I made an xml file in drawable and its gradient is set below
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@android:id/background">
<shape>
<corners android:radius="5dip" />
<gradient
android:angle="270"
android:centerColor="#808080"
android:centerY="0.75"
android:endColor="#808080"
android:startColor="#808080" />
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<corners android:radius="2dip" />
<gradient
android:angle="270"
android:centerColor="#09488D"
android:centerY="0.75"
android:endColor="#09488D"
android:startColor="#09488D" />
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<corners android:radius="5dip" />
<gradient
android:angle="270"
android:centerColor="#09488D"
android:centerY="0.75"
android:endColor="#09488D"
android:startColor="#09488D" />
</shape>
</clip>
</item>
</layer-list>
Then this xml use it in seekbar's background But the color does not change :(
Upvotes: 2
Views: 18379
Reputation: 1786
If you want to change the color of the progress you have to provide a 9patch drawable for your progressDrawable.
You can find the one currently being used in android-sdk/platforms/(the-api-your-app-is-targeting)/data/res/drawable/scrubber_primary_holo.9
(that's for api 15)
Ive found that the easiest way is to simple open that image, edit the colors, save the image as a 9patch image and put in your applications /drawable folder.
Upvotes: 0
Reputation: 7888
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
Upvotes: 4