I try to draw Unicode string to SurfaceView, but I cannot get it work. Here is my code.
public class TestView extends SurfaceView implements SurfaceHolder.Callback {
private Paint painter = null;
public LyricView(Context context) {
super(context);
initialize();
}
protected void initialize() {
getHolder().addCallback(this);
setFocusable(true);
painter = new Paint(Paint.ANTI_ALIAS_FLAG);
painter.setStyle(Paint.Style.STROKE);
painter.setStrokeWidth(3);
painter.setColor(Color.WHITE);
painter.setTextSize(50);
}
...
...
@Override
protected void onDraw(Canvas canvas) {
String test = "日本語";
canvas.drawText(test, 100, 100, painter);
}
}
if I change my string to unicode escape as below, it work. I don't know why.
String test = "\u65E5\u672C\u8A9E";
Please help.
Thank you.