我想在画布月份的文字垂直沿着屏幕高度绘制.
绘制初始化:
this.paint = new Paint();
this.paint.setAntiAlias(true);
this.paint.setDither(true);
this.paint.setSubpixelText(true);
this.paint.setColor(color_text_dark);
this.paint.setTextAlign(Align.RIGHT);
画画:
// Set the scale to the widest month
float scale = getHeight() / this.max_month_width;
String month_string = FULL_MONTH_NAME_FORMATTER.
format(active_month_calendar.getTime());
canvas.save();
canvas.translate(getWidth(), 0);
canvas.rotate(-90);
canvas.scale(scale, scale);
canvas.drawText(month_string, 0, 0, this.paint);
canvas.restore();
结果在hdpi屏幕上看起来不错,但在xhdpi上非常难看和像素化.
我在各种设备上做了更多测试,并了解结果取决于Android版本,而不是屏幕密度和分辨率.
代码在2.x平台上运行良好,但在4.0.3上不起作用.假设,这里改变了Android绘图实现.
完整代码你可以看到here.
hdpi版本2.3.5(也测试2.2)
xhdpi版本4.2(也测试了4.1,4.0.3)
为油漆抗锯齿尝试不同的变化,亚像素文本没有效果.我该如何解决这个问题?