我尝试在中心制作文字。文本动态添加。
public class GraphicsView extends View {
private static final String MY_TEXT = "ORANGE";
private Path mArc;
private Paint mPaintText;
public GraphicsView(Context context) {
super(context);
mArc = new Path();
RectF oval = new RectF(100,200,340,260);
mArc.addArc(oval, 135, -100);
mPaintText = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaintText.setStyle(Paint.Style.FILL_AND_STROKE);
mPaintText.setColor(Color.BLACK);
mPaintText.setTextSize(35f);
}
@Override
protected void onDraw(Canvas canvas) {
canvas.drawTextOnPath(MY_TEXT, mArc, 0, 10, mPaintText);
invalidate();
}
}
一切都很好,但如果我想要显示另一个词 - 它不会在中心。
我可以知道如何计算中心和放置的单词吗?是否可以在不同的屏幕分辨率下制作?