使用 ButterKnife 会使应用变慢吗?

Does the use of ButterKnife make app slower?

我已经开始在我的 android 应用程序中使用 ButterKnife 只是为了看看它和 "findViewById" 之间的区别,我发现 UI 有点迟钝而且打开 activity 或片段时会有一点延迟。 ButterKnife 会造成这种小延迟吗?

不,不是。让我们检查一下 id 在幕后做了什么。它使用注解接口,做同样的事情,不同之处仅在于编译时间,当你构建的文件缓存为空时。

每个 Bind 注释与通常的查找视图、id 和保存到本地视图 id 的集合一样。这很简单,因为那里没有什么特别的。只需检查自定义接口实现,您可以自己实现简单的Butterknife

Butterknife uses compile-time annotations which means there is no additional cost at run-time. Instead of slow reflection, code is generated ahead of time. Calling bind delegates to this generated code that you can see and debug. This means that Butterknife does not slow down your app at all! (Source)

这应该可以澄清您的顾虑。必须有另一个问题导致你的滞后。也许用CPU Profiler分析一下,找出原因。