0

I would like to draw a custom shape, that work as a progress bar.

Any tips about how can I create this? (Example bellow)

I only found out how to do circle, donuts and bar only. =/

Example

jNewbie
  • 334
  • 1
  • 15

1 Answers1

0

You can create custom shape by extending with Progressbar

Try this code and customize according to you need

public class CustomBar extends ProgressBar {

 

        Paint p = new Paint();

        int progress;

        public CustomBar(Context context) {

                super(context);

                p.setColor(Color.GREEN);

        }



@Override
protected synchronized void onDraw(Canvas canvas) {

                canvas.drawLine(0, 0, getWidth(), 0, p);

                canvas.drawLine(0, 0, 0, getHeight(), p);

                canvas.drawArc(new Rect(0, 0, getWidth(),  getHeight()), 40, true, p);

                /**

                 * Whatever drawing is needed for your Layout

                 * But make sure you use relative lenghts and heights

                 * So you can reuse your Widget.

                 * Also use the Progress Variable to draw the filled part

                 * corresponding to getMax()

                 */

        }

}  

For further details check the link below

https://pastebin.com/pKhK3YCa

Fazal Hussain
  • 1,129
  • 12
  • 28