Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NestedScrollView wont't scroll to the end when used with CollapsingToolbarLayout

I want to use NestedScrollView with CollapsingToolbarLayout. In NestedScrollView there is really long content. Unfortunately I can't scroll to the end. Some of this long content is cut. What is strange when I turn screen, scrolling works fine and all content is visible.

<android.support.design.widget.CoordinatorLayout
    android:fitsSystemWindows="true"
    android:layout_height="match_parent"
    android:layout_width="match_parent">

    <android.support.design.widget.AppBarLayout
        android:fitsSystemWindows="true"
        android:layout_height="wrap_content"
        android:layout_width="match_parent">

        <android.support.design.widget.CollapsingToolbarLayout
            android:fitsSystemWindows="true"
            android:layout_height="match_parent"
            android:layout_width="match_parent"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <ImageView
                android:fitsSystemWindows="true"
                android:layout_height="wrap_content"
                android:layout_width="match_parent"
                android:scaleType="centerCrop"
                android:src="@drawable/u8"
                app:layout_collapseMode="parallax"/>

            <android.support.v7.widget.Toolbar
                android:layout_height="?attr/actionBarSize"
                android:layout_width="match_parent"
                app:layout_collapseMode="pin"/>

        </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.NestedScrollView
        android:clipToPadding="false"
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

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

            <!-- lots of widgets-->

        </LinearLayout>

    </android.support.v4.widget.NestedScrollView>

</android.support.design.widget.CoordinatorLayout>

EDIT: I noticed that height of cut content is the same as Toolbar height.

like image 969
Aleksander Mielczarek Avatar asked Dec 16 '15 07:12

Aleksander Mielczarek


People also ask

What is difference between nested ScrollView and NestedScrollView?

Nested scrolling is enabled by default. Show activity on this post. NestedScrollView is just like ScrollView, but in NestedScrollView we can put other scrolling views as child of it, e.g. RecyclerView. But if we put RecyclerView inside NestedScrollView, RecyclerView's smooth scrolling is disturbed.

How do I stop NestedScrollView scrolling?

setnestedscrollingenabled set it to false.

Why use coordinator layout android?

As a container for a specific interaction with one or more child views. By specifying Behaviors for child views of a CoordinatorLayout you can provide many different interactions within a single parent and those views can also interact with one another.


2 Answers

Answer taken from here. Adding paddingBottom to NestedScrollView resolved this issue for me:

android:paddingBottom="<toolbar height in collapsed state>"
like image 56
Darshan Dorai Avatar answered Oct 08 '22 20:10

Darshan Dorai


I was also facing the similar issue where the NestedScrollView wouldn't scroll to the end when the keyboard is open.

Placing the AppBarLayout after the NestedScrollView did the trick for me. Do let me know if it works for you.

like image 22
Mithun Raman Avatar answered Oct 08 '22 19:10

Mithun Raman