40

This is my seekbar:

<SeekBar
    android:id="@+id/seek1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    android:progressDrawable="@drawable/style_progressbar"
    android:thumb="@drawable/style_progressbar_circle"
    android:progress="20" />

This is style_progressbar.xml:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@android:id/background">
        <shape android:shape="rectangle" >
            <corners android:radius="5dp" />
            <gradient
                android:angle="270"
                android:endColor="@color/gris_hint"
                android:startColor="@color/gris_hint" />
        </shape>
    </item>
    <item android:id="@android:id/secondaryProgress">
        <clip>
            <shape android:shape="rectangle" >
                <corners android:radius="5dp" />
                <gradient
                    android:angle="270"
                    android:endColor="@color/gris"
                    android:startColor="@color/gris" />
            </shape>
        </clip>
    </item>
    <item android:id="@android:id/progress">
        <clip>
            <shape android:shape="rectangle" >
                <corners android:radius="5dp" />
                <gradient
                    android:angle="270"
                    android:endColor="@color/gris"
                    android:startColor="@color/gris" />
            </shape>
        </clip>
    </item>
</layer-list>

And this is style_progressbar_circle.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/red_scrubber_control_disabled_holo" android:state_enabled="false"/>
    <item android:drawable="@drawable/red_scrubber_control_pressed_holo" android:state_pressed="true"/>
    <item android:drawable="@drawable/red_scrubber_control_focused_holo" android:state_selected="true"/>
    <item android:drawable="@drawable/red_scrubber_control_normal_holo"/>
</selector>    

This is how I see it in Lollipop

Seekbar Lollipop

This is how it should look, this is how it looks on Kitkat and lower versions.

Seekbar KitKat

Any idea? I've got some issues with layouts on Lollipop but this is the only one I can't solve for my own.

fdermishin
  • 3,519
  • 3
  • 24
  • 45
deimian86
  • 1,127
  • 1
  • 11
  • 26

2 Answers2

62

The Material seek bar has split track enabled by default. You need to turn it off.

<SeekBar
    ....
    android:splitTrack="false" />
alanv
  • 23,966
  • 4
  • 93
  • 80
1

use android.support.v7.widget.AppCompatSeekBar and app:splitTrack for all device.

  <android.support.v7.widget.AppCompatSeekBar
      app:splitTrack="false"
      android:splitTrack="false"/>
Rasoul Miri
  • 11,234
  • 1
  • 68
  • 78
  • 1
    Declaring the `android` tag outside a v21 layout or API 21 project warns of incompatibility and using the `app` tag does not seem to work alone. Have you experienced this issue? – Abandoned Cart Jun 02 '19 at 16:47