Android: how to invalidate multiple parts of the screen

I need to be able to selectively invalidate several (about 20) rectangles on the screen for performance reasons, so I tried the following:

Vector<Rect> myRects = new Vector<Rect>();

// ... add some Rects to myRects

for (Rect r : myRects) {
    invalidate(r);
}

However, this seems to invalidate the union of everyone Rect's, forming one large rectangle that encompasses all the small ones that I'm trying to invalidate.

How can I cancel several areas on the screen and only those areas?

+3
source share
1 answer

One rectangle is invalid, then in onDraw()check your list and call Invalidate()with the next until the list is empty.

Drawable InvalidateDrawable() .

0

Source: https://habr.com/ru/post/1745723/


All Articles