【发布时间】:2017-01-14 21:00:27
【问题描述】:
我在嵌套滚动视图(位于 CoordinatorLayout 内)中使用了 Recycler View:
<android.support.v4.widget.NestedScrollView
android:id="@+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/sections_recycler_view_linearlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" />
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
在上述回收器的适配器中,我使用 setNestedScrollingEnabled 作为 false 以编程方式添加了子回收器视图。
我的问题是: 当我滚动子回收器时,一旦它的滚动完成,父回收器就会滚动到顶部,就好像我再次设置它的适配器一样。我没有添加任何代码来通知适配器或滚动到最顶部的回收站项目或再次设置适配器。我无法弄清楚这种奇怪行为的原因。
任何帮助将不胜感激.. !!!
【问题讨论】:
-
你为什么需要这个结构?一个单一的回收审查可以做同样的事情。
-
因为我希望父回收器垂直滚动,而子回收器水平滚动。父回收器与可折叠工具栏一起使用以显示工具栏动画,并且将在运行时决定父回收器视图中有多少子回收器。
-
Child Recycler 在滚动时卡住,即使我删除了 setHasFixedSize 或者即使我将其设置为 true 或 false。
-
检查一下,这可能会有所帮助,我遇到了类似的问题:stackoverflow.com/questions/36923948/…
标签: android android-recyclerview android-coordinatorlayout android-nestedscrollview