2

I'm developing a library with some widgets for Android but I need to use a bitmap as a ProgressBar with a color that fills it as the progress bar. The below image describes what I mean:

A drop of water that indicates with the blue color the % of water

My first guess is to create a PNG with inverse transparent background and add a square painting the invisible background like this:

Using transparency I can add the progress Bar

Is there a better way to do this? What would you do to create this as a ProgressBar.

Thank you.

chntgomez
  • 1,725
  • 3
  • 16
  • 28
  • I would do exactly what you are depicting in image. I would move the blue color using translate animation, and fill the transparent area with the blue image, based on the percentage required. – Iqbal S Apr 01 '15 at 18:50
  • Start by looking at how the framework's [horizontal progress bar background](https://github.com/android/platform_frameworks_base/blob/master/core/res/res/drawable/progress_horizontal_material.xml) is structured. Then read the documentation for [ClipDrawable](http://developer.android.com/reference/android/graphics/drawable/ClipDrawable.html) and think about how you might represent this as a `` containing a `` that wraps a ``. Keep in mind that `ClipDrawable` clips based on the progress bar's progress level. – alanv Apr 01 '15 at 21:51

0 Answers0