4

I want to create a layout as displayed in picture .

I follow many blogs but didn't get the proper answer. Main problem is to create the circular progress which is showing with the help of some graphics. However not able to move towards success.

Path p = new Path();
    p.moveTo(70, 10);
    p.lineTo(25, 100);
    p.lineTo(100, 50);
    p.lineTo(0, 50);
    p.lineTo(75, 100);
    p.lineTo(50, 0);
    // chk

    // //complete code
     ShapeDrawable progress1 = new ShapeDrawable(new ArcShape(180, -45));
     progress1.setIntrinsicHeight(50);
     progress1.setIntrinsicWidth(50);
     progress1.getPaint().setColor(Color.BLUE);
     progress1.getPaint().setStyle(Style.STROKE);
     progress1.getPaint().setStrokeWidth(5);

     ShapeDrawable progress2 = new ShapeDrawable(new ArcShape(0, 180));
     progress2.setIntrinsicHeight(50);
     progress2.setIntrinsicWidth(50);
     progress2.getPaint().setARGB(50, 200, 54, 54);
     progress2.getPaint().setStyle(Style.STROKE);
     progress2.getPaint().setStrokeWidth(5);
     iView.setImageDrawable(progress2);
     iView1.setImageDrawable(progress1);

enter image description here

Ratna deep verma
  • 141
  • 1
  • 11
  • which parts are you stuck on? – arnorhs Apr 14 '14 at 07:33
  • First thing ,i am not able to create the progress bar in circular form and colorful as like in picture . In android progress bar is so simple. So right now i even don't know how to do this. But currentally i am trying to do this with the help of canvas but in that i am not able to draw something like circular which is also circular at it's end points. – Ratna deep verma Apr 14 '14 at 07:40

1 Answers1

1

Without knowing which part you're stuck on, what you'd probably do is make a custom view where you define the drawing code in its onDraw method.

You can probably get away with drawing arced lines using a thick stroke in the corresponding target color. To make the ends of the arc rounded, configure the Paint object's properties to suit your needs, iirc the right method to use is Paint#setStrokeCap

arnorhs
  • 10,383
  • 2
  • 35
  • 38
  • But as i show in picture can you can suggest me that how an i hide the lines. And is it right approach to follow the desired layout which is showing in first picture..Thanks – Ratna deep verma Apr 14 '14 at 07:58
  • I would not use a shape drawable, and just draw directly using canvas's `drawRect` method – arnorhs Apr 14 '14 at 08:03