2013-04-30 34 views
1

当我在TextView中绘制文本或在LinearLayout中填充背景颜色时,我发现了一些在Windows编程中找不到的奇怪现象。Android:如何关闭文本视图和布局的抗锯齿

The background color in the Layout and text color in TextView, 
are not a single color, but a mixed color 
when I capture the phone screen and see and check the pixel value on the PC. 

如果我设置文本颜色或0xFF1010FF(蓝色), 大多数像素是0xFF1010FF, 他们几个都是0xFF1010FD或0xFF1010FE,略有不同的颜色值, 我想这是抗锯齿。

所以布局背景颜色。 (每个像素的1或2值差异)

这些效果在android中比PC颜色看起来更平滑,但我不想像这样填充颜色,只是具有精确的颜色值。

Can I make the color with an exact single value? 

我试过TextPaint.getPaint().setAntiAlias(false);但它没有工作。

此外,我可能无法为布局背景使用TextPaint。

这个问题将是大多数Android开发者的常见问题, 所以我会非常感谢您的任何建议。

谢谢。

回答

1

我想这一点,和它的工作对我来说:

TextView textView1 = (TextView) findViewById(R.id.textView1); 
textView1.getPaint().setAntiAlias(false); 

这样有效地禁止antialising,所以国际海事组织它不是做,但如果它是你在找什么,你去那里。