我的应用程序中有一个奇怪的错误,Paint.measureText(String text)
在我看来它应该返回相同的值时返回一个不同的答案。最后,当我使用Paint对象绘制文本时,我将其跟踪到ANTI_ALIAS_FLAG被更改,即
Paint text_paint = new Paint();
text_paint.setStyle(Paint.Style.FILL);
text_paint.setTextSize(50);
text_paint.setColor(Color.BLACK);
Log.d("MyApp","AA1="+text_paint.isAntiAlias());
canvas.drawText("SomeText", 10, 10, text_paint);
Log.d("MyApp","AA2="+text_paint.isAntiAlias());
使用Android版本4.2.1生成日志输出
04-29 19:30:00.702: D/MyApp(18806): AA1=false
04-29 19:30:00.707: D/MyApp(18806): AA2=true
measureText
的结果取决于此ANTI_ALIAS_FLAG。所以我的问题是