Draw a text on a circle path in android

喜夏-厌秋 提交于 2019-12-21 14:58:28

问题


I need to draw a text on a circle path. I have tried the drawTextOnPath() method. But for texts like "fertile window" in the image attched, the text rotates and is not readable.

Code I have used :

customPath2.addArc(mCircleRectF, 30F, 64.28F);
    customPaint2.setAntiAlias(true);
    customPaint2.setDither(true);
    customPaint2.setStrokeWidth(mCircleStrokeWidth);
    customPaint2.setColor(Color.parseColor("#93BE66"));
    customPaint2.setStyle(Paint.Style.STROKE);
    customPaint2.setStrokeCap(Paint.Cap.ROUND);
    canvas.drawPath(customPath2, customPaint2);

    titlePaint.setColor(Color.parseColor("#ffffff"));
    titlePaint.setAntiAlias(true);
    titlePaint.setTypeface(Typeface.MONOSPACE);  titlePaint.setLetterSpacing(0.07F);
    titlePaint.setTextAlign(Paint.Align.CENTER);
    titlePaint.setTextSize(35f);

    canvas.drawTextOnPath("FERTILE WINDOW", customPath2, 0, 8, titlePaint);

来源:https://stackoverflow.com/questions/38657335/draw-a-text-on-a-circle-path-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!