Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide the toolbar in a ViewPager when using Scrolling RecyclerView?

I've got a toolbar in a view-pager (tabbed toolbar with horizontal swipe navigation) and each tab has its own fragment with a recyler_view. I now want to hide the toolbar when my recyler_view scrolls. In my fragment i added the on scroll-listener and want to call there a method in its activity class to hide the toolbar. The toolbar is created in the activity. How can I call this method from my fragment? or would it be better to implement this hiding method in my fragment itself. But then how can i "contact" my toolbar, that is created in the activity and not in the fragment. I have found solutions, but none of them talks about a recylcer_view in a fragment and view-pager for tabbed navigation. Would be great if you can help me...

like image 254
Basem Abdelfattah Avatar asked Jan 28 '15 10:01

Basem Abdelfattah


1 Answers

I just had the same problem as you and solved it by using a library ObservableScrollView.

Have a look at ViewPagerTabRecyclerViewFragment.

If you don't want to use a library you still can have a look at how they implemented it as the lib is Open Source

like image 50
Frame91 Avatar answered Oct 15 '22 14:10

Frame91