android-view-invalidate

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

Why is requestLayout being called directly after invalidate

给你一囗甜甜゛ 提交于 2019-11-27 02:43:03
问题 I'm learning about custom views and wanted to learn about invalidate() and requestLayout() . Please refer to this answer and its diagram: https://stackoverflow.com/a/25846243/4243687 invalidate() tells Android that the state of the view has changed and needs to be re-drawn. requestLayout() means the size of the view may have changed and needs to be remeasured, and then re-drawn. invalidate() will invoke dispatchDraw() , draw() , and onDraw() hence it re-renders the view. requestLayout() on