android - 为什么partial invalidate会跨越整个View?

标签 android android-view android-view-invalidate

我正在尝试使 android View 部分无效。我使用 View.invalidate( l, t, b, r ) 它似乎正确地使垂直(顶部和底部)值无效,但是,无论我使用哪个左右值,它都会使整个 View 无效。

例如,我的 View 是灰色的。我希望使绿色区域无效,但是,它会使绿色和红色区域无效。它总是跨越整个 View 的整个水平方向。我尝试输入较小的值,例如 View.invalidate(0, 0, 50, 50),它仍然会导致此行为。

Image Link (not enough rep to post images)

为什么会这样?

最佳答案

行为随着硬件加速而改变,这是 Honeycomb 之后的默认设置。现在,当您invalidate() 提供脏区域的 View 时,不会设置剪辑边界 (canvas.getClipBounds())。但是,只有与脏区域相交的对象才会被重绘。

引用 this渲染管线作者 Romain Guy 的回答。

关于android - 为什么partial invalidate会跨越整个View?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31495176/

相关文章:

android - 不使用 invalidate(Rect) 只更新 View 的一部分

android - 如何在此动画后休息/初始状态 View ?

android - 在 android 模拟器中运行 react-native

Android Chrome 检查设备黑屏

android - 如何使用 React Native Share API 共享 App 链接?

android - 在 View 类 android 中加载布局 xml 文件

android - 在没有任何布局的情况下向 Activity 添加按钮

android - 更新 ListView 页脚

android - Kotlin协程-多个错误导致到达catch block 之前崩溃