不使用 invalidate(Rect) 只更新一部分 View [英] Updating only a portion of View without using invalidate(Rect)

查看:22
本文介绍了不使用 invalidate(Rect) 只更新一部分 View的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.有没有其他方法可以只更新一部分视图?
2.使用不推荐使用的方法有什么后果?

1.Are there any other way to update only a portion of view?
2.What are the consequences of using a deprecated method?

推荐答案

根据android文档,只需要调用invalidate()方法,因为重绘区域是内部计算的.

According to the android documentation, just call the invalidate() method as the redrawing area is calculated internally.

来自查看文档此方法在 API 级别 28 中已弃用.在 API 14 中切换到硬件加速渲染降低了脏矩形的重要性.在 API 21 中,给定的矩形被完全忽略,取而代之的是内部计算的区域.因此,鼓励客户端只调用 invalidate().

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

Deprecated methods may be removed in the future and when that happens, your application might not compile. So it's better to not use them :)

这篇关于不使用 invalidate(Rect) 只更新一部分 View的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆