静态布局绘制文字,文字模糊,权重不均,不清楚。
我想绘制双字节字符的文本(如中文、日文等)
谁知道如何解决这个问题。以及如何在 StaticLayout 中设置字体
TextPaint textPaint = new TextPaint();
// textPaint.setARGB(1, 0, 0, 0);
textPaint.setFlags(TextPaint.FAKE_BOLD_TEXT_FLAG);
textPaint.setColor(Color.rgb(0, 0, 0));
textPaint.setFakeBoldText(true);
textPaint.setTextSize(16.0F);
StaticLayout layout = new StaticLayout(cityName,textPaint,w/WCOUNT-2-2,
Alignment.ALIGN_CENTER,1.0F,0.0F,true);
int wh = layout.getHeight();
int offerseth = rect.height()/2-wh/2;
int ww = layout.getWidth();
int offersetw = rect.width()/2-ww/2;
canvas.translate(rect.left+offersetw,rect.top+offerseth);
layout.draw(canvas);
canvas.translate(-(rect.left+offersetw),-(rect.top+offerseth));