android Staticlayout绘制文字模糊

时间:2013-01-31 02:54:18

标签: android text draw

Staticlayout绘制文字,单词模糊,重量不均匀,不清楚。

我想绘制双字节字符的文本(如中文,日文等)

谁知道如何解决这个问题。以及如何在StaticLayout中设置Font

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)); 

2 个答案:

答案 0 :(得分:3)

对于较小的字体大小,我看到你没有这样做:

textPaint.setAntiAlias(true);

答案 1 :(得分:0)

我找到了自己的答案。

使用的字体太小。将字体大小更改为20.0F会使文本看起来很好。