我想写这样的弯曲文字:
我该怎么做?
答案 0 :(得分:35)
大声笑,这很有趣,我只是试着制作文字曲线,你可以尝试一下:
package pete.android.study;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import android.view.View;
public class GraphicsView extends View {
private static final String MY_TEXT = "xjaphx: Draw Text on Curve";
private Path mArc;
private Paint mPaintText;
public GraphicsView(Context context) {
super(context);
mArc = new Path();
RectF oval = new RectF(50,100,200,250);;
mArc.addArc(oval, -180, 200);
mPaintText = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaintText.setStyle(Paint.Style.FILL_AND_STROKE);
mPaintText.setColor(Color.WHITE);
mPaintText.setTextSize(20f);
}
@Override
protected void onDraw(Canvas canvas) {
canvas.drawTextOnPath(MY_TEXT, mArc, 0, 20, mPaintText);
invalidate();
}
}
答案 1 :(得分:4)
听起来像是draw text on a path。因此,您应该create a path that is an Arc然后在其上绘制文本,这应该是完美的。我希望有所帮助。