我正在研究为什么我的一些RecyclerViews表现不佳。当需要绘制视图的整个内容时,UI尤其滞后 使用systrace我遇到了一个大框架,其中RecyclerView布局了它的视图:
如您所见,重复绘制相同的视图。在systrace中,我在RecyclerView框架上找到了以下描述:
OnLayout has been called by the View system. If this shows up too many times in Systrace, make sure the children of RecyclerView do not update themselves directly. This will cause a full re-layout but when it happens via the Adapter notifyItemChanged, RecyclerView can avoid full layout calculation.
我的RecyclerView的视图使用谷歌的data binding和可观察的值
更新TextView的含义我不使用textView.setText(titleTxt)
,而title.set(titleTxt)
其中title
属于ObservableField<String>
类型。
所以我显然不是在调用notifyItemChanged
,而只是更新绑定到布局的对象上的可观察字段。
在这种情况下使用数据绑定是否有效?如果是这样,那么数据绑定的意义何在?移动UI主要由列表组成。
答案 0 :(得分:0)
不幸的是,随着Kotlin的到来,Google将数据绑定留在了后面,因此,如果您认为它像我一样正在减慢速度,那就停止使用它或一起搬到Kotlin。 Kinda很讨厌我们尝试与不断破裂并被抛在后面的事物一起工作,但这正是Google决定成为的事物。