Android的帆布setShadowLayer大大降低性能帆布、性能、Android、setShadowLayer

2023-09-05 05:10:32 作者:白冷

我在写一篇Android的画布的应用程序,我期待添加阴影,但我注意到一个伟大的减缓,当我将它们添加到我的油漆对象。我的code是简单,它看起来是这样的:

I'm writing a canvas app on android and I'm looking to add shadows, but I've noticed a great slow-down when I add them to my paint object. My code is simple it looks like this:

...
Paint paint = new Paint();
paint.setShadowLayer(8.f, 0, 0, 0xff000000); // this line makes terribly slow drawing
canvas.drawRect(left, top, right, bottom, paint);

我怎样才能让这快?

How can I make this faster?

推荐答案

使用,而不是它绘制的图像图标:)

Use an image icon instead of drawing it :)

是的阴影是昂贵的。