开发者

Getting the dirty region inside draw()

If I invalidate() a part of my custom view with a dirty rect parameter, how do I get the dirty rect inside the draw() method? The clipping rect of the canvas is not the same - in my experience, it's typ开发者_运维技巧ically few times larger.


If the dirty rect is not the same as the one you passed to invalidate(), it is because another View or region of the screen was also invalidated.


get the clipRect from the passed in Canvas object to onDraw method. This clipRect (Canvas::getClipBounds) is actually the invalidated Rect.

The clipRect is larger sometimes because different invalidated areas are unioned together so that one event is fired instead of firing multiple for performance reasons.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜