I have activity which has drawer attached to it. Each menu of the drawer is a fragment, and under one of the menu I have a fragment with TabLayout
, and each tab contains a RecyclerView
. So now, when I scroll the RecyclerView
, tab layout is getting hidden but ToolBar
remains at the top. What I need is to ToolBar
to get hidden(scrollFlags:scroll|enterAlways
), and TabLayout
should get shown at the top.
So current setup is:
Activity with attached DrawerLayout -> Fragment with TabLayout -> Tab Fragment 1 with RecyclerView -> Tab Fragment 2 with RecyclerView
Less Code More Effective
Hello @Vishal i have found too much for you. because i am also searching this topic before some time.
I have found one brilliant library named MaterialViewPager this is fully customize with what you want to hide in scroll mode.
See the video on https://www.youtube.com/watch?v=r95Tt6AS18c
Can you use the support design library? It has this behavior built in to do exactly what you have described. It uses CoordinatorLayout to accomplish this.
<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:animateLayoutChanges="true" > <android.support.design.widget.AppBarLayout 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.TabLayout android:id="@+id/tabanim_tabs" android:layout_width="match_parent" android:layout_height="wrap_content" /> </android.support.design.widget.AppBarLayout> <android.support.v4.view.ViewPager android:id="@+id/tabanim_viewpager" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> <android.support.design.widget.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_alarm_add_white_48dp" app:layout_anchor="@id/tabanim_viewpager" app:layout_anchorGravity="bottom|right|end" android:layout_margin="16dp" /> </android.support.design.widget.CoordinatorLayout>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With