Search code examples
androidandroid-layoutandroid-drawablexml-drawablelayer-list

Progress Bar with a gap between left and right section


How do I create a progress bar with blue progress indication, grey background and a transparent gap (black in the example) between the sections: progress bar with a gap between sections

I've tried to play around with shapes, to create the left section with border only on the right. The closest example that I could find was shape with bottom stroke, but I was unable to modify it to display the gap required in my case.

Unless I get shape to work, I might end up using setSecondaryProgress() in code.


Solution

  • use setProgressDrawable, you will need to create your custom Drawable in the code as what you want cannot be done in xml, you will need to override onLevelChange and call invalidateSelf, see Custom ProgressBar for a sample implementation