我有包含 4 个 ImageView 的 GroupView。
当我更改一个 View 的参数(例如重新缩放图像或旋转)时,这会导致重新绘制整个布局。
我想防止重绘整个布局,只想重绘特定的 View 。
最佳答案
当然可以。
myView.invalidate()
参见: https://developer.android.com/reference/android/view/View.html#invalidate()
Drawing is handled by walking the tree and recording the drawing commands of any View that needs to update. After this, the drawing commands of the entire tree are issued to screen, clipped to the newly damaged area.
The tree is largely recorded and drawn in order, with parents drawn before (i.e., behind) their children, with siblings drawn in the order they appear in the tree. If you set a background drawable for a View, then the View will draw it before calling back to its onDraw() method. The child drawing order can be overridden with custom child drawing order in a ViewGroup, and with setZ(float) custom Z values} set on Views.
To force a view to draw, call invalidate().
关于android - 有没有办法只重绘一个 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40889545/