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 co
What causes this for me is "exitUntilCollapsed" line in my CollapsingToolbarLayout:
app:layout_scrollFlags="scroll|exitUntilCollapsed">
It causes problem when used with "scroll". I couldn't also use marginBottom because I have an instant translate option which refreshes the TextViews with new content, and when that happens it mysteriously decides to scroll even further more, which ends up in a really bad looking empty space at the bottom.
I solved it using "enterAlwaysCollapsed" instead and moved my toolbar to the very top, outside the collapse. It's not exactly what I want but so far I couldn't find a solution.
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.
Use app:layout_behavior="@string/appbar_scrolling_view_behavior" property and nested scroll view it will work
<android.support.design.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.support.design.widget.AppBarLayout
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="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/task_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
I had the same issue. One of the reasons for this bug was not setting the SupportActionBar
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
(I didn't to do it because I needed toolbar only for the collapsing toolbar to work as expected and I thought it wasn't important to setSupportActionBar)
And the other one was: it was working inside the activity, but in a fragment wasn't working correctly (maybe it was an issue of that specific version of support library that I used)
Due to Toolbar pinned(with CollapsingToolbar). Nestedscrollview failed to adjust the bottom view with the screen.
If you set toolbar on the setSupportActionBar. NestedScrollView will fit with the screen.
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
It's been a while since asking the question. But maybe setting minHeight
attribute in CollapsingToolbarLayout like in this answer might help somebody as well.