gpt4 book ai didi

android - 两次绘制相同的矩形看起来会有所不同

转载 作者:行者123 更新时间:2023-11-29 01:24:55 24 4
gpt4 key购买 nike

我有一个自定义 View ,我发现有些线条看起来比其他线条更暗。经过一番调查,我发现这不是一种感觉,而是现实。绘制它们的代码是相同的,但它被调用了多次。如果它被调用一次,该行是浅灰色的。如果我再次调用它,该行将变成深灰色。为什么? (连接 4 与 Android 5.1)

bgPaint = new Paint();
bgPaint.setAntiAlias(true);
bgPaint.setStyle(Paint.Style.FILL);
bgPaint.setColor(Color.LTGRAY);

borderPaint = new Paint();
borderPaint.setAntiAlias(true);
borderPaint.setStyle(Paint.Style.STROKE);
borderPaint.setColor(Color.DKGRAY);

canvas.drawRoundRect(new RectF(tile.getX() + 1, tile.getY() + 1, tile.getXx() - 1, tile.getYy() - 1),
roundRadius, roundRadius, borderPaint);
canvas.drawRoundRect(new RectF(tile.getX() + 1, tile.getY() + 1, tile.getXx() - 1, tile.getYy() - 1),
roundRadius, roundRadius, bgPaint);

这是一个例子。右下方的图 block 颜色较深。

example

更新:第一个drawRoundRect负责。我注释掉了第二个,没有它我可以重现这种行为。但老实说 - 第二次调用将正确呈现它 - 深灰色。但为什么第一个调用使它更轻?

最佳答案

因为 .setAntiAlias(true); 形状的边缘与已经存在的颜色混合。

因此,不是像第一次那样将 DKGRAY 与白色混合,而是将 DKGRAYDKGRAY 混合并提供更暗的外观。

关于android - 两次绘制相同的矩形看起来会有所不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34566173/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com