1

当我在 TextView 中绘制文本或在 LinearLayout 中填充背景颜色时,我发现了一些在 Windows 编程中找不到的奇怪东西。

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 开发人员来说,这个问题将是一个常见问题,因此我将非常感谢您的任何建议。

谢谢你。

4

1 回答 1

1

我试过这个,它对我有用:

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

这有效地禁用了抗锯齿,因此 IMO 不需要这样做,但如果它是您正在寻找的,那么您就可以了。

于 2013-04-30T07:38:56.400 回答