How to disable RecyclerView scrolling to make the layout listen its ScrollView parent?
11,320
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.
Author by
Jahir Fiquitiva
Colombian 🇨🇴 | Creative and Passionate Full Stack Developer
Updated on June 09, 2022Comments
-
Jahir Fiquitiva almost 2 years
I'm trying to put a
RecyclerView
, inside aScrollView
. But theScrollView
doesn't scrolls and theRecyclerView
does but I don't want it to... What can I do?I tried with this class https://stackoverflow.com/a/30222721/4864104 and in fact the
RecyclerView
doesn't scroll anymore, but neither does theScrollView
.Any help to make the
ScrollView
work even with the disabledRecyclerView
? Thanks in advance.This is my layout:
<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>