如何在滚动视图中滚动RecyclerView [英] how to scroll RecyclerView in scrollview
问题描述
如何在滚动视图中滚动RecyclerView上方的所有内容
how to scroll all above RecyclerView in scrollview
我必须在滚动视图中实现RecyclerView,如下所示,但不能滚动RecyclerView.
I have to implement RecyclerView in scrollview show as below code, but not scroll RecyclerView.
请给出答案
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/horizontalScrollView"
android:layout_marginTop="10dp">
<RelativeLayout...
<android.support.v7.widget.RecyclerView
android:id="@+id/rvpouch"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:nestedScrollingEnabled="false"
android:layout_below="@+id/textView3">
</android.support.v7.widget.RecyclerView>
</RelativeLayout>
</ScrollView>
推荐答案
请勿在ScrollView
中使用RecyclerView
.使用NestedScrollView
代替ScrollView
.
Don't use RecyclerView
inside ScrollView
. Use NestedScrollView
instead of ScrollView
.
NestedScrollView
就像ScrollView
一样,但是它支持表演 作为新老的嵌套滚动父级和子级 版本的Android.默认情况下,嵌套滚动处于启用状态.
NestedScrollView
is just likeScrollView
, but it supports acting as both a nested scrolling parent and child on both new and old versions of Android. Nested scrolling is enabled by default.
例如:
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView_one"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false">
</android.support.v7.widget.RecyclerView>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView_two"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false">
</android.support.v7.widget.RecyclerView>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView_three"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
使用属性android:nestedScrollingEnabled="false"
进行平滑滚动.
Use attribute android:nestedScrollingEnabled="false"
for smooth scrolling.
这篇关于如何在滚动视图中滚动RecyclerView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!