Hide Toolbar with CoordinatorLayout + TabLayout + ViewPager

1

Good morning, I'm trying to implement the google Material Design features and wanted to hide the Toolbar when I scroll in the ViewPager (it has a RecyclerView inside), however I'm not getting the desired effect (although I have all the necessary tags in XML). I think the problem is that I have AppBar inside a LinearLayout (I used it because ViewPAger was cut down and that solved the problem), however when the shot still does not have the intended effect. I submit the layouts in question:

skeleton_view.xml

<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">

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

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/appbarlayout">
    <android.support.v7.widget.Toolbar
        android:id="@+id/tool_bar"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:background="@color/colorTeal200"
        app:popupTheme="@style/AppTheme"
        android:elevation="6dp"
        app:layout_scrollFlags="scroll|enterAlways"/>

    <android.support.design.widget.TabLayout
        android:layout_width="match_parent"
        android:layout_height="52dp"
        app:tabGravity="fill"
        app:tabMode="fixed"
        android:layout_gravity="bottom"
        android:background="@color/colorText"
        app:tabIndicatorColor="@color/colorTeal500"
        android:id="@+id/tab_layout"/>
</android.support.design.widget.AppBarLayout>

<android.support.v4.view.ViewPager
    android:id="@+id/view_pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</LinearLayout>

<android.support.design.widget.FloatingActionButton
    android:id="@+id/gallery_fab"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_marginRight="160dp"
    android:layout_marginBottom="16dp"
    android:src="@drawable/ic_photo_library_white_24px"
    app:backgroundTint="@color/colorAccent700"
    app:borderWidth="0dp"
    app:elevation="12dp"
    app:pressedTranslationZ="12dp"
    android:visibility="invisible"/>

<android.support.design.widget.FloatingActionButton
    android:id="@+id/camera_fab"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_marginRight="90dp"
    android:layout_marginBottom="16dp"
    android:src="@drawable/ic_camera_alt_white_24px"
    app:backgroundTint="@color/colorAccent700"
    app:borderWidth="0dp"
    app:elevation="12dp"
    app:pressedTranslationZ="12dp"
    android:visibility="invisible"/>

<android.support.design.widget.FloatingActionButton
    android:id="@+id/floating_button"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:layout_gravity="bottom|right"
    android:layout_margin="16dp"
    android:src="@drawable/ic_add_white_24px"
    app:backgroundTint="@color/colorAccent700"
    app:borderWidth="0dp"
    app:elevation="12dp"
    app:layout_behavior="com.draft.meal.testing.ScrollFABAction.ScrollOffBottomBehaviour"
    app:layout_anchorGravity="bottom|right|end"
    app:layout_anchor="@id/view_pager"/>

skeleton.xml

<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:id="@+id/nav_drawer"
android:layout_alignParentRight="true"
android:fitsSystemWindows="true"
android:elevation="7dp"
tools:openDrawer="end"
android:gravity="left"
android:layout_gravity="end">

<include layout="@layout/skeleton_view"/>

<android.support.design.widget.NavigationView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/navigation_view"
    android:layout_gravity="end"
    android:gravity="left"
    app:headerLayout="@layout/navigation_header"
    app:elevation="4dp"
    app:menu="@menu/drawer">
</android.support.design.widget.NavigationView>

Thanks for the help!

    
asked by anonymous 29.04.2016 / 12:07

0 answers