在我当前的应用程序中,我使用 invalidate(Rect) 来更新我当前视图的一部分,但从 API 28 开始,此方法已被弃用。
所以我的问题是:
1.有没有其他方法可以只更新一部分视图?
2.使用不推荐使用的方法有什么后果?
在我当前的应用程序中,我使用 invalidate(Rect) 来更新我当前视图的一部分,但从 API 28 开始,此方法已被弃用。
所以我的问题是:
1.有没有其他方法可以只更新一部分视图?
2.使用不推荐使用的方法有什么后果?
根据android文档,只需调用该invalidate()
方法,因为重绘区域是内部计算的。
从查看文档
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().
将来可能会删除不推荐使用的方法,当这种情况发生时,您的应用程序可能无法编译。所以最好不要使用它们:)