1

I am a lot confused with styles. Need help. How can I create a progressBar style in xmls, generic, but backgroung red and progressbar green? thanks.

Tibor
  • 589
  • 2
  • 7
  • 20
  • See if this post helps you out. http://stackoverflow.com/questions/2638161/how-to-change-android-indeterminate-progressbar-color – Krylez Nov 22 '11 at 21:41

1 Answers1

1

Use a layer list which provides the background and the item to use to "fill in" the progress.

Something like this - my_progress_bar.xml (put this in your Drawable folder)

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@android:id/background"
          android:drawable="@drawable/progressbar" > </item>
    <item android:id="@android:id/progress">
        <clip android:drawable="@drawable/progressfill"/>
    </item>
</layer-list>

Then, instantiate a SeekBar in your View:

seekBar = new SeekBar(context);
seekBar.setProgressDrawable(getResources().getDrawable(R.drawable.my_progress_bar));

Note that SeekBar is a subclass of ProgressBar, but you should be able to do something similar for a progressbar.

LuxuryMode
  • 33,401
  • 34
  • 117
  • 188
  • is there any way I can write over the progressBar and not with another control around it?, i.e. I want to put % completed inside the progress bar – Tibor Nov 23 '11 at 11:23
  • I dont understand, in your example, where does I write red and green? – Tibor Nov 23 '11 at 19:30