1

I'm trying to customise my SeekBar. I've looked at a few SO questions on the subj, specifically: Android: SeekBar with custom drawable and Android - styling seek bar

The problem I'm having is that the background of the SeekBar doesn't appear at all. Progress and SecondaryProgress work fine now that I'm using the 9 patch image approach, however using the same for the background didn't allow me to customise the colour.

Here's my seekbar layout:

<SeekBar
    android:id="@+id/seekbar"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical"
    android:layout_weight="1"
    android:maxHeight="@dimen/one"
    android:minHeight="@dimen/one"
    android:progressDrawable="@drawable/seekbar_style"
    android:thumb="@drawable/video_player_seekbar_thumb"/>

The thumb part works fine. Here's my seekbar_style:

<?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/video_player_seekbar_background" />
    <item android:id="@android:id/secondaryProgress">
        <scale android:scaleWidth="100%">
            <selector>
                <item android:state_enabled="true">
                    <color android:color="#80FFFFFF" />
                </item>
                <item android:drawable="@drawable/abc_scrubber_primary_mtrl_alpha" />
            </selector>
        </scale>
    </item>
    <item android:id="@android:id/progress">
        <scale android:scaleWidth="100%">
            <selector>
                <item android:state_enabled="true">
                    <color android:color="#FFFFFF" />
                </item>
                <item android:drawable="@drawable/abc_scrubber_primary_mtrl_alpha" />
            </selector>
        </scale>
    </item>
</layer-list>

And my video_player_seekbar_background looks like this:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line">

    <stroke android:width="2dp" android:color="@color/red" />

</shape> 
Community
  • 1
  • 1
vkislicins
  • 3,331
  • 3
  • 32
  • 62

0 Answers0