Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make custom progress bar with indicator image, like whatsapp?

I created an XML file named customprogressbar.xml in your res->drawable folder:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- Define the background properties like color etc -->
    <item android:id="@android:id/background">
    <shape>
        <gradient
                android:startColor="#000001"
                android:centerColor="#0b131e"
                android:centerY="1.0"
                android:endColor="#0d1522"
                android:angle="270"
        />
    </shape>
   </item>

  <!-- Define the progress properties like start color, end color etc -->
  <item android:id="@android:id/progress">
    <clip>
        <shape>
            <gradient
                android:startColor="#007A00"
                android:centerColor="#007A00"
                android:centerY="1.0"
                android:endColor="#06101d"
                android:angle="270"
            />
        </shape>
    </clip>
    </item>
</layer-list>

And

<ProgressBar
    android:id="@+id/progressBar1"
    style="?android:attr/progressBarStyleHorizontal"
    android:progressDrawable="@drawable/custom_progressbar"         
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

Now I have the colors but I need to put indicator image, between in fill and remainig.

enter image description here

Any idea?

like image 799
Cabezas Avatar asked Feb 08 '23 16:02

Cabezas


1 Answers

What you are looking at is a Seekbar rather than a plain Progressbar. The circle indicator is called a thumb and you can add any image you like (as well as a custom progress bar also).

<SeekBar ...
    android:thumb="@drawable/your_thumb"
    android:progressDrawable="@drawable/progress_bar_layers"
 />
like image 107
Nick Cardoso Avatar answered Feb 10 '23 23:02

Nick Cardoso