问题描述
我试图将RecyclerView
放在ScrollView
内.但是ScrollView
不能滚动,而RecyclerView
可以滚动,但是我不希望它...我该怎么办?
I'm trying to put a RecyclerView
, inside a ScrollView
. But the ScrollView
doesn't scrolls and the RecyclerView
does but I don't want it to... What can I do?
我尝试了此类 https://stackoverflow.com/a/30222721/4864104 ,实际上是RecyclerView
不再滚动,但ScrollView
也不滚动.
I tried with this class https://stackoverflow.com/a/30222721/4864104 and in fact the RecyclerView
doesn't scroll anymore, but neither does the ScrollView
.
即使禁用了RecyclerView
,是否有任何帮助使ScrollView
正常工作?预先感谢.
Any help to make the ScrollView
work even with the disabled RecyclerView
? Thanks in advance.
这是我的布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="jahirfiquitiva.projects.activities.DeveloperActivity">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
<ScrollView
android:id="@+id/osv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/toolbar"
android:fillViewport="true"
android:gravity="center"
android:overScrollMode="never">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp">
<ImageView
android:id="@+id/photoJahir"
android:layout_width="144dp"
android:layout_height="144dp"
android:layout_gravity="center"
android:gravity="center" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lineSpacingMultiplier="1.2"
android:paddingBottom="@dimen/lists_padding"
android:paddingTop="@dimen/lists_padding"
android:text="@string/developer_bio"
android:textSize="@dimen/abc_text_size_subtitle_material_toolbar" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/dividers_about_section"
android:alpha="0.3"
android:background="@color/primary" />
<RecyclerView
android:id="@+id/buttonsGrid"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/lists_padding"
android:paddingTop="@dimen/lists_padding" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/dividers_about_section"
android:alpha="0.3"
android:background="@color/primary" />
<View
android:layout_width="match_parent"
android:layout_height="72dp" />
</LinearLayout>
</ScrollView>
推荐答案
通过将滚动视图更改为 NestedScrollView 并设置recyclerView.setNestedScrollingEnabled(false)
具有最高的性能,无需覆盖布局管理器.
You could easily achieve it by changing your scroll view into a NestedScrollView and setting recyclerView.setNestedScrollingEnabled(false)
Has the highest performance and No need to override the layout manager.
这篇关于如何禁用RecyclerView滚动以使布局侦听其ScrollView父级?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!