Sid
Sid

Reputation: 209

horizontal progressbar with circle indicator android

I want to display circle(dot) indicator at the end of progress value. It is like this :-

horizontal progressbar indicator image

Here is my progressbar xml file:-

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

    <item android:id="@android:id/background">
        <shape>
            <corners android:radius="5dip" />
            <gradient
                android:angle="270"
                android:centerColor="#EBEBEB"
                android:centerY="0.75"
                android:endColor="#EBEBEB"
                android:startColor="#EBEBEB" />
        </shape>
    </item>

    <item android:id="@android:id/secondaryProgress">
        <clip>
            <shape>
                <corners android:radius="5dip" />
                <gradient
                    android:angle="270"
                    android:centerColor="#EBEBEB"
                    android:centerY="0.75"
                    android:endColor="#EBEBEB"
                    android:startColor="#EBEBEB" />
            </shape>
        </clip>
    </item>

    <item android:id="@android:id/progress">
        <clip>
            <shape>
                <corners android:radius="5dip" />
                <gradient
                    android:angle="270"
                    android:centerColor="#00FFB7"
                    android:centerY="0.75"
                    android:endColor="#00FFB7"
                    android:startColor="#00FFB7" />
            </shape>
        </clip>
    </item>
</layer-list>

It is currently looking like this :-

current progressbar

Please help me to add circular indicator. Thanx

Upvotes: 2

Views: 1087

Answers (1)

Harshad Pansuriya
Harshad Pansuriya

Reputation: 20990

Add Gradle dependency:

dependencies {
   compile 'com.github.rey5137:material:1.2.4'
}

and in xml code use this way

 <com.rey.material.widget.Slider
            android:id="@+id/slider_sl_continuous_disable"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:padding="16dp"
            android:enabled="false"
            app:v_styleId="@array/slider"/>

you can define silder in your themes.xml file

 <array name="slider">
        <item>@style/LightSlider</item>
    </array>

and in styles.xml file define this way

 <style name="LightSlider" parent="Material.Widget.Slider">
        <item name="sl_primaryColor">@color/colorPrimary</item>
    </style>

Output :

enter image description here

Hope this will help you. Happy Coding..

Upvotes: 2

Related Questions