简体   繁体   English

使用滚动RecyclerView时如何在ViewPager中隐藏工具栏?

[英]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.

相关问题 滚动recyclerview时如何在状态栏下完全隐藏工具栏 - How to hide toolbar fully under status bar when scrolling recyclerview 如何在viewpager中隐藏recyclerview滚动的顶部布局 - how to hide top layout on recyclerview scrolling in viewpager 在NestedScrollView中使用recyclerView时如何隐藏滚动条上的工具栏 - how to hide toolbar on scroll when using recyclerView inside NestedScrollView 无法滚动 RecyclerView,尝试在滚动时隐藏工具栏 - Can't scroll RecyclerView, when try to hide toolbar on scrolling 当您停止在android中滚动listview / recyclerview时,如何隐藏或显示部分隐藏的工具栏/操作栏 - How to hide or show the partially hidden toolbar/actionbar when you stop scrolling the listview/recyclerview in android 如何在recyclelerView向下滚动时折叠后隐藏工具栏 - How to hide toolbar after collapsing while recyclerView scrolling down 在 Fragment 上滚动时如何隐藏工具栏 - How to hide toolbar when scrolling on Fragment 通过在Fragment中滚动recyclerview来隐藏活动中的工具栏? - Hide toolbar in activity by scrolling a recyclerview inside the Fragment? 工具栏不会隐藏在DrawerLayout中的Scrolling recyclerview上 - Toolbar doesn't hide on Scrolling recyclerview in DrawerLayout 快速滚动时,如何解决recyclerview中viewpager上的意外行为? - How to fix unexpected behavior on viewpager in recyclerview when fast scrolling?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM