Search code examples
androidseekbar

Secondary progress not visible


Secondary progress in SeekBar is not visible.

If I am not giving progress in drawable it is overriding secondary progress as primary progress

seekbar_progress.xml

<?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:id="@android:id/secondaryProgress">
        <clip>
                <shape android:shape="line">
                    <stroke
                        android:width="3dp"
                        android:color="@color/color_status_bar" />
                </shape>
        </clip>
    </item>
</layer-list> 

Custom SeekBar is showing on progress but not secondary progress. When deleting

<item android:id="@android:id/progress">
    <clip>
        <shape android:shape="line">
            <stroke
                android:width="3dp"
                android:color="@color/color_status_bar" />
        </shape>
    </clip>
</item>

from XML it is taking secondary progress as primary progress.


Solution

  • Use Secondary Progress attribute in xml, this worked for me.

    <SeekBar
         android:id="@+id/seekbar_voice"
         android:layout_width="0dp"
         android:layout_height="wrap_content"
         android:layout_gravity="center"
         android:layout_weight="1"
         android:progressDrawable="@drawable/seekbar_progress"
         android:secondaryProgress="100"
         android:splitTrack="false"
         android:thumb="@drawable/custom_thumb" />