I try make text in center. Text added dynamically.
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();
}
}
Everything is fine, but if I want show another word - it plased not in center.
May I know how calculate center and placed words in it? Is it possible make on different screen resolutions?