除非Horizo​​ntalScrollView用另一个View包装,否则视图更新过多

时间:2018-12-31 23:16:30

标签: android horizontalscrollview

因此,我有一个包含>>> spam = [] >>> eggs = spam >>> spam += [1] >>> eggs [1] >>> spam = [] >>> eggs = spam >>> spam = spam + [1] >>> eggs [] 的活动。这是一个清理过的xml。

HorizontalScrollView

还有我的<android.support.v4.widget.DrawerLayout style="@style/style_DrawerLayout"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <include layout="@layout/toolbar_std"/> <include layout="@layout/btn_bar_scroll"/> <android.support.v7.widget.RecyclerView android:layout_width="match_parent" android:layout_height="match_parent"/> </LinearLayout> <include layout="@layout/navigation_view"/> </android.support.v4.widget.DrawerLayout> (为清楚起见,仅显示了三个按钮)

btn_bar_scroll

它工作正常,完全符合预期。除了使用<HorizontalScrollView android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <LinearLayout android:layout_width="wrap_content" android:layout_height="match_parent" android:orientation"horizontal"> <Button android:layout_width="wrap_content" android:layout_height="match_parent" android:text="BTN1" android:drawableTop="@drawable/ic1"/> <Button android:layout_width="wrap_content" android:layout_height="match_parent" android:text="BTN2" android:drawableTop="@drawable/ic2"/> <Button android:layout_width="wrap_content" android:layout_height="match_parent" android:text="BTN3" android:drawableTop="@drawable/ic3"/> </LinearLayout> </HorizontalScrollView> 时,我注意到,每当以任何一种方式拖动滚动条时,整个页面上的每个视图都会更新(即使Show GPU View Updates也更新)。表现不是很好。

奇怪的是,通过将Toolbar换成另一个视图,例如HorizontalScrollView,停止了不必要的视图更新(轻拂时只有FrameLayout更新)。有什么建议吗?我宁愿没有理由似乎也没有多余的HorizontalScrollView

FrameLayout

0 个答案:

没有答案
相关问题