仅更新View的一部分而不使用invalidate(Rect)

问题描述 投票:2回答:1

在我当前的应用程序中,我使用invalidate(Rect)来更新当前视图的一部分,但从API 28开始,不推荐使用此方法。 所以我的问题是:

1.有没有其他方法只更新视图的一部分? 2.使用弃用方法的后果是什么?

android view redraw android-view-invalidate
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().

将来可能会删除不推荐使用的方法,当发生这种情况时,您的应用程序可能无法编译。所以最好不要使用它们:)

© www.soinside.com 2019 - 2024. All rights reserved.