简体   繁体   中英

Canvas drawText, how to rotate and how to change “anchor-point”?

Good evening,

It is about an android app.

I would like to use the method Canvas.drawText(...). But I don't know how I can rotate the text. I need the text at a certain position at a certain angle. Do you know how I can achieve this?

Next question, usually the point to which the position coordinates are refering is the lower left corner. I want to change this "anchor-point" to the lower center. Is that possible? The pivot-point of the rotation should be the same.

I guess simple questions, but I don't know how to do this. Thanks for help.

here is a basic example of drawing text on a path, to get it how you want you should mess with the path and the paint Path , Paint

    Paint paint = new Paint();
    Path path = new Path();
    paint.setColor(Color.BLACK);
    path.moveTo(canvas.getWidth()/2, 0);
    path.lineTo(canvas.getWidth()/4, 400);
    canvas.drawTextOnPath("text manipulated", path, 0, 0, paint);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM