Search code examples
androidandroid-coordinatorlayoutandroid-design-libraryandroid-nestedscrollviewandroiddesignsupport

NestedScrollView not scrolling with CoordinatorLayout


Trying to scroll content within CoordinatorLayout with NestedScrollView is not working for following layout for fragment:

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <com.google.android.material.appbar.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </com.google.android.material.appbar.AppBarLayout>

    <androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        android:scrollbars="none"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="24dp"
            android:orientation="vertical">

            <!-- Scrollable content -->

        </LinearLayout>

    </androidx.core.widget.NestedScrollView>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

How can I make the content inside NestedScrollView scrollable? windowSoftInput is set to adjustResize for the hosting activity and the theme is Theme.MaterialComponents.Light.NoActionBar. Also the activity is not fullscreen.


Solution

  • Had to apply the workaround mentioned here: https://stackoverflow.com/a/36322516 as nothing else was working for me. So marking this answer as accepted until a working solution is posted as an answer