0

I used the VerticalSeekBar descripted on How can I get a working vertical SeekBar in Android?. It's a pretty good job and works well for me. But when I set progressDrawable in layout xml, it doesnot work. Any suggestions?

Here is the snippet in my layout xml:

<com.aidufei.widget.VerticalSeekBar
android:id="@+id/volume_bar"
android:layout_width="16dip"
android:layout_height="160dip"
android:background="@drawable/volume_bar_bg"
android:paddingBottom="20dip"
android:progressDrawable="@drawable/vol_seekbar_style"
android:thumb="@drawable/volume_thumb"
android:thumbOffset="-13dip" />

and vol_seekbar_style.xml:`

<item android:id="@android:id/background">
    <shape>
        <corners android:radius="5dip" />

        <gradient
            android:angle="360"
            android:centerColor="#868781"
            android:centerY="1"
            android:endColor="#868781"
            android:startColor="#868781" />
    </shape>
</item>
<item android:id="@android:id/progress">
    <clip>
        <shape>
            <gradient
                android:angle="90"
                android:endColor="#3B3934"
                android:startColor="#3B3934" />

            <corners android:radius="5dip" />
        </shape>
    </clip>
</item>

` VerticalSeekBar.java:https://gist.github.com/maxhis/4739037

Community
  • 1
  • 1
iStar
  • 1,112
  • 12
  • 20

1 Answers1

0

Here you have, a working example:

<myapp.VerticalSeekBar
       android:id="@+id/mySeekBar"
       android:layout_width="wrap_content"
       android:layout_height="200dp"
       android:layout_gravity="center_horizontal"
       android:layout_marginBottom="10dp"
       android:max="50"
       android:maxHeight="11dip"
       android:minHeight="11dip"
       android:paddingLeft="10dp"
       android:paddingRight="10dp"
       android:progress="25"
       android:progressDrawable="@drawable/seekbar_progress"
       android:thumb="@drawable/bg_seekbar_ball" />

@drawable/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"
        android:drawable="@drawable/bg_seekbar_bellow"/>
    <item
        android:id="@android:id/progress"
        android:drawable="@drawable/bg_seekbar_above"/>

</layer-list>

Hope it helps in some way ;)
Take care.

GuilhE
  • 11,591
  • 16
  • 75
  • 116