1

I've created a custom seekbar and it works perfect for 4.1 devices, but on 4.2 and 4.3 devices it does not show my background, it just leaves it blank.

This is what I do:

mySeekbar.setProgressDrawable(getResources().getDrawable(R.drawable.seekbar_progress));
mySeekbar.setBackgroundDrawable(getResources().getDrawable(R.drawable.slider_shape));

seekbar_progress.xml:

<layer-list 
xmlns:android="http://schemas.android.com/apk/res/android">
<item 
    android:id="@android:id/background">
        <bitmap 
            android:src="@drawable/slider_background_part"
            android:tileMode="repeat">
        </bitmap>
</item>
<item 
    android:id="@android:id/progress">
    <layer-list 
        xmlns:android="http://schemas.android.com/apk/res/android" >
        <item>
            <clip>
               <color
                   xmlns:android="http://schemas.android.com/apk/res/android"
                   android:color="@color/my_slider_color"/>
            </clip>
        </item>
        <item>
            <clip >
                <bitmap 
                    xmlns:android="http://schemas.android.com/apk/res/android"
                    android:src="@drawable/slider_foreground_part"
                    android:tileMode="repeat"/>
            </clip>
        </item>
    </layer-list>
</item>

In this file I'm repeating an image for progress and background, and for the progress, I give it a certain color. Then I still need to set a shape for my background. If I don't do this, the background just remains blank.

slider_shape.xml:

<shape 
    xmlns:android="http://schemas.android.com/apk/res/android">
    <corners android:radius="0dp"/>
</shape>

Can somebody help me here?

dumazy
  • 13,857
  • 12
  • 66
  • 113

0 Answers0