2

I need a seek bar which color need this

enter image description here

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 :(

MBMJ
  • 5,323
  • 8
  • 32
  • 51
  • 1
    This might help you:http://stackoverflow.com/questions/7056803/making-a-custom-skinny-progressbar-seekbar and http://www.mokasocial.com/2011/02/create-a-custom-styled-ui-slider-seekbar-in-android/ – Hiral Vadodaria Jul 24 '12 at 06:38

2 Answers2

4

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

AkashG
  • 7,868
  • 3
  • 28
  • 43
0

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.

Slickelito
  • 1,786
  • 20
  • 28
  • that's interesting. what tools do you use to open, edit and save the 9 patch? – faizal Jul 09 '14 at 19:41
  • 1
    The designer did it for me but I assume he used photoshop. If you don't want to use the holo progressbar you can see this answer : http://stackoverflow.com/questions/2739186/android-how-do-i-change-the-height-of-a-progressbar/21474806#21474806 if you use that approach you can just provide a color instead of having to change the 9-patch image. – Slickelito Jul 11 '14 at 06:53