[英]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. 我在视图分页器中有一个工具栏(带有水平滑动导航的选项卡式工具栏),每个选项卡都有自己的带有recyler_view的片段。 I now want to hide the toolbar when my recyler_view scrolls.
我现在想要在我的recyler_view滚动时隐藏工具栏。 In my fragment i added the on scroll-listener and want to call there a method in its activity class to hide the toolbar.
在我的片段中,我添加了on scroll-listener,并希望在其activity类中调用一个方法来隐藏工具栏。 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.
我找到了解决方案,但没有一个讨论片段中的recylcer_view和用于选项卡式导航的view-pager。 Would be great if you can help me...
如果你能帮助我会很棒......
I just had the same problem as you and solved it by using a library ObservableScrollView . 我遇到了和你一样的问题,并使用一个库ObservableScrollView解决了它。
Have a look at ViewPagerTabRecyclerViewFragment . 看看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 如果您不想使用库,您仍然可以查看它们是如何实现它的,因为lib是开源的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.