McF*_*ane 6 performance android systrace android-recyclerview android-databinding
我正在研究为什么我的一些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的视图使用谷歌的数据绑定与可观察的值.
更新TextView的意思我不使用,textView.setText(titleTxt)
但title.set(titleTxt)
在哪里title
类型ObservableField<String>
.
显然我不是在调用,notifyItemChanged
而只是更新绑定到布局的对象上的可观察字段.
在这种情况下使用数据绑定在性能方面是错误的吗?如果是这样,那么数据绑定的意义何在?移动UI主要由列表组成.
不幸的是,随着 Kotlin 的到来,Google 抛弃了数据绑定,所以如果你认为它像我一样拖慢了速度,那就停止使用它或者一起转向 Kotlin。对于我们来说,尝试处理那些不断破坏和落后的东西有点糟糕,但这正是谷歌决定成为的样子。
归档时间: |
|
查看次数: |
554 次 |
最近记录: |