android - How to draw an arc at run time on the circular clock view? -


i'm working on android app need draw arc on circular clock , have tried following codes.please fin below image.i have draw arc on circular clock.thank you..

initial method:

private void initclock() {     height=getheight();     width=getwidth();     padding=numeralspacing +50;     fontsize=(int) typedvalue.applydimension(typedvalue.complex_unit_sp,23,getresources().getdisplaymetrics());     int min=math.min(height,width);     radius=min/2-padding;     handtruncation=min/20;     hourhandtruncation=min/7;     paint=new paint();     isinit=true; }  @override protected void ondraw(canvas canvas) {     if(!isinit)     {         initclock();     }     //canvas.drawcolor(color.black);     drawcircle(canvas);     drawcenter(canvas);     drawnumeral(canvas);     drawhands(canvas);     postinvalidatedelayed(500);     invalidate(); }  private void drawcircle(canvas canvas) {     paint.reset();     paint.setcolor(getresources().getcolor(android.r.color.white));     paint.setstrokewidth(5);     paint.setstyle(paint.style.stroke);     paint.setantialias(true);     canvas.drawcircle(width/2,height/2,radius+padding-10,paint); }  private void drawcenter(canvas canvas) {     paint.setstyle(paint.style.fill);     canvas.drawcircle(width/2,height/2,12,paint); }  private void drawnumeral(canvas canvas) {     paint.settextsize(fontsize);     for(int number:numbers)     {         string tmp=string.valueof(number);         paint.gettextbounds(tmp,0,tmp.length(),rect);         double angle=math.pi/6 *(number-3);         int x=(int) (width/2+math.cos(angle) *radius-rect.width()/2);         int y=(int) (height/2+math.sin(angle) *radius+rect.height()/2);         canvas.drawtext(tmp,x,y,paint);     } }  private void drawhand(canvas canvas,double loc,boolean ishour) {     double angle=math.pi*loc/30-math.pi/2;     int handradius=ishour ? radius-handtruncation-hourhandtruncation:radius-handtruncation;     canvas.drawline(width/2,height/2,(float)(width/2+math.cos(angle)*handradius),(float)(height/2+math.sin(angle)*handradius),paint); }  private void drawhands(canvas canvas) {     calendar c=calendar.getinstance();     float hour=c.get(calendar.hour_of_day);     hour= hour>12 ? hour-12 : hour;     drawhand(canvas,(hour+c.get(calendar.minute)/60)*5f,true);     drawhand(canvas,c.get(calendar.minute),false); } 

i need fin coordinates of arc endpoints drawn on circular clock.

please find image below enter image description here


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -