2

I need to create a component such as progressbar (as you can see in image) to act as slider. I searched Internet and find somethings like: Custom Drawable for ProgressBar/ProgressDialog but it was not useful for me. Please tell me how can i create this component?

enter image description here

Community
  • 1
  • 1
Hesam
  • 52,260
  • 74
  • 224
  • 365

1 Answers1

4

Create your own drawable, for example progressbar.xml and set android:progressDrawable="@drawable/progressbar attrubute on your progress bar

write in progressbar.xml drawable this code:

<?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>
            <nine-patch android:src="@drawable/progressbar_body" android:dither="true" />
        </clip>
    </item>

</layer-list>

and replace @drawable/progressbar_bg and @drawable/progressbar_body with you own 9 patch png images

pleerock
  • 18,322
  • 16
  • 103
  • 128
  • I tried this and the progress value seems to be ignored in that case. So it always appears at 100%. Any suggestions? – RaB Jun 19 '12 at 05:31
  • ups, googling helps http://stackoverflow.com/questions/7141469/android-seekbar-set-custom-style-using-nine-patch-images – RaB Jun 19 '12 at 05:33