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

天涯浪子 提交于 2021-01-27 18:24:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!