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.
精彩评论