Search code examples
androidandroid-coordinatorlayoutandroid-appbarlayoutandroid-nestedscrollview

Android nested scrollview anchored to AppBArLayout


So, I have a situation, I need to create something like this:

enter image description here

Where white background view is nested view, and the image with all the elements is in the appbar. Now, I managed to create it without NestedScrollView being over the AppbarLayout, but how can I achieve that, how can I put NestedScrollView above AppBarLayout without loosing any functionality?


Solution

  • In oreder to make this work, you need to do following:

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

    Where overlapTop is how much it will overlap and layout_behavior is the thing you need here. Hope it helps.