如何在滚动视图中滚动RecyclerView

编程入门 行业动态 更新时间:2024-10-18 20:31:48
本文介绍了如何在滚动视图中滚动RecyclerView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何在滚动视图中滚动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 like ScrollView, 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

本文发布于:2023-10-08 01:28:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1471113.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视图   如何在   RecyclerView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!