Updating only a portion of View without using invalidate(Rect)

1.3k Views Asked by At

In my current application I am using invalidate(Rect) to update a portion of my current view but as of API 28 this method is deprecated.
So my questions are:

1.Are there any other way to update only a portion of view?
2.What are the consequences of using a deprecated method?

1

There are 1 best solutions below

2
On BEST ANSWER

According to the android documentation, just call the invalidate() method as the redrawing area is calculated internally.

From view docs This method was deprecated in API level 28. The switch to hardware accelerated rendering in API 14 reduced the importance of the dirty rectangle. In API 21 the given rectangle is ignored entirely in favor of an internally-calculated area instead. Because of this, clients are encouraged to just call invalidate().

Deprecated methods may be removed in the future and when that happens, your application might not compile. So it's better to not use them :)