I want to personalise the default Android seekbar to:
I read about nine patch image and created 6 png images. The first three are for the gray progress bar (progressDrawable), as shown below:
Right image
Center image
Left image
The result should be:
The blue images represent the progress and are as follows:
Right image
Center image
Left image
And the thumb is as follows:
My question is, how can I use nine patch image to generate the custom seekbar exactly as the first picture and how can I apply this to my seekbar?
I think it shouldn't be complex. You don't have to make 6 images to fulfill your needs. Just create 2 nine-patches for background, progress. And thumb.png. Here is your XML:
<SeekBar
android:id="@+id/my_seekbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:progressDrawable="@drawable/seekbar_progress"
android:thumb="@drawable/thumb">
in your seekbar_progress
:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@android:id/background">
<nine-patch android:src="@drawable/progressbar_bg" android:dither="true"/>
</item>
<item android:id="@android:id/progress">
<clip xmlns:android="http://schemas.android.com/apk/res/android"
android:clipOrientation="horizontal"
android:gravity="left">
<nine-patch android:src="@drawable/progressbar_status" android:dither="true"/>
</clip>
</item>
</layer-list>
Do remember that your thumb
should have blank space on top when creating so it looks like you wanted.
Hope this helps.