1

I want my whole screen to scroll but only my recycler will scroll at the moment. This occurs despite all elements being placed in a linear layout inside a Scroll View.

Any ideas where the error is? Here's the relevant code.

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="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=".NoodleDetailActivity">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <ImageView
                android:id="@+id/noodleImage"
                android:layout_width="match_parent"
                android:layout_height="200dp"
                android:adjustViewBounds="false"
                android:scaleType="centerCrop"
                app:srcCompat="@mipmap/ic_launcher" />

            <TextView
                android:id="@+id/description"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/border_bottom"
                android:fontFamily="sans-serif-smallcaps"
                android:hapticFeedbackEnabled="false"
                android:padding="30dp"
                android:text="TextView"
                android:textSize="18sp" />

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/extras_recycler"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="0dp"
                android:background="#F2F2F2"
                android:padding="0dp" />
        </LinearLayout>
    </ScrollView>

</androidx.constraintlayout.widget.ConstraintLayout>

This is what it looks visually.

demo appearance

  • Use NestedScrollView instead of ScrollView. Please see this topic: https://stackoverflow.com/questions/27083091/recyclerview-inside-scrollview-is-not-working – Tiberiu Neagu Oct 04 '19 at 12:15

1 Answers1

0

Found out: it seems best practice is to set the recyclerView to be the whole layout and make it contain multiple view types. I won't be using a nested scroll view.