4

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?

Cabezas
  • 9,329
  • 7
  • 67
  • 69

2 Answers2

7

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"
 />
Nick Cardoso
  • 20,807
  • 14
  • 73
  • 124
  • 2
    Thank you very much. That's perfect. I have to make a custom seekBar http://stackoverflow.com/questions/16163215/android-styling-seek-bar – Cabezas Feb 23 '16 at 11:16
1

If "indicator image" means that round circle there, then I'm not sure if this can be done with ProgressBar.

This looks to me more like a SeekBar then a ProgressBar. They are practically the same except, SeekBar has the "thumb" attribute. This could work for you:

<SeekBar
   android:id="@+id/seekBar"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:thumb="@drawable/thumb_image"
   android:progressDrawable="@drawable/customprogressbar.xml"
/>
Zoran P
  • 336
  • 1
  • 9