Question

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

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top