saulmm / CoordinatorBehaviorExample

2.71k stars 590 forks source link

Also how can we use tablayout with this layout, can you please explain me that... #25

Open deepeshalways opened 8 years ago

HerRomero commented 7 years ago

Editing my own answer, I've got a much cleaner solution. Just put the TabLayout on top of the NestedScrollView and above the TabLayout put a space of the Toolbar height. After that set the overlap of the NestedScrollView to be the same height as the space and you are set!

During scroll the space is barely visible.

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="none"
    app:behavior_overlapTop="?attr/actionBarSize"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

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

        <Space
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize" />

        <android.support.design.widget.TabLayout>