Android Drawing text on canvas -


i drawing speedometer on imageview contains bg. use code ticks , values

    (int = 0; < 270; += 5) {         if (i % 30 == 0) {             scalepaint.setstrokewidth(2f);             canvas.drawline(3.55f * wquarter, 2 * hquarter,                     3.78f * wquarter, 2 * hquarter, scalepaint);             canvas.drawtext(string.valueof(i), 3.5f * wquarter,                     2f * hquarter, scalepaint);           } else {             scalepaint.setstrokewidth(1.5f);             canvas.drawline(3.65f * wquarter, 2 * hquarter,                     3.78f * wquarter, 2 * hquarter, scalepaint);          }         canvas.rotate(5f, 2 * wquarter, 2 * hquarter);     } 

the ticks drawn should, problem text rotated canvas. how can keep text position while resetting rotation? of upside down or @ +90 -90

here isenter image description here

you can use canvas.save() save status of variables affecting canvas (rotation, distortion, ...), canvas.restore() return status.
in case need rearrange content of loop little bit :

canvas.save(); canvas.rotate(...); {draw line} canvas.restore(); canvas.drawtext(...); 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -