问题
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:
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 :)
来源:https://stackoverflow.com/questions/52647158/updating-only-a-portion-of-view-without-using-invalidaterect