简体   繁体   English

如何在 ViewPager + RecyclerView 中使用 AppBarLayout 的提升滚动?

[英]How to use AppBarLayout's lift-on-scroll with ViewPager + RecyclerView?

I have an activity layout that's like this:我有一个这样的活动布局:

<CoordinatorLayout>
    <AppBarLayout>
        <Toolbar />
        <TabLayout />
    </AppBarLayout>
    <ViewPager />
</CoordinatorLayout>

Then, in the activity, the viewpager is populated with three fragments.然后,在活动中,viewpager 填充了三个片段。 Each of these fragments has a layout like this:这些片段中的每一个都有这样的布局:

<FrameLayout>
    <FrameLayout>
        <RecyclerView />
        <Other views />
    </FrameLayout>
    <Other views />
</FrameLayout>

Now, in other views where RecyclerView is not used for the content, the lift-on-scroll works just fine (for instance, when using NestedScrollView instead of RecyclerView ).现在,在RecyclerView不用于内容的其他视图中,提升滚动工作得很好(例如,当使用NestedScrollView而不是RecyclerView )。 However, with RecyclerView it doesn't work.但是,使用RecyclerView它不起作用。 How should it be configured to make it work?它应该如何配置以使其工作?

在应用栏上添加这个:

app:liftOnScroll="true"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在ViewPager中滚动RecyclerView? - How to scroll RecyclerView inside a ViewPager? 如何在 viewpager 中使用 recyclerview smothScrollToPosition - How to use recyclerview smothScrollToPosition in a viewpager 使用 MaterialDesignComponents 在 RecyclerView Scroll 上隐藏 AppBarLayout - Hiding AppBarLayout on RecyclerView Scroll using MaterialDesignComponents AppBarLayout + NestedScrollView + RecyclerView不会滚动 - AppBarLayout + NestedScrollView + RecyclerView won't scroll 为什么 Recyclerview 不在 AppBarLayout 内滚动 - Why Recyclerview doesn't scroll inside AppBarLayout RecyclerView startSmoothScroll() 与 AppBarLayout 的滚动量不正确? - RecyclerView startSmoothScroll() incorrect scroll amount with AppBarLayout? 滚动页面时滚动ViewPager的RecyclerView - Scroll ViewPager's RecyclerView when page gets scrolled MotionLayout 与 Viewpager 的 Recyclerview - MotionLayout with Viewpager's Recyclerview 使用RecyclerView的AppBarLayout可以在不让RecyclerView过度滚动的情况下工作吗? - Can AppBarLayout with RecyclerView works without letting RecyclerView over-scroll? 滚动问题-带有包含RecyclerViews的片段的CoordinatorLayout + AppBarLayout + ViewPager - Scroll problems - CoordinatorLayout + AppBarLayout + ViewPager with Fragments containing RecyclerViews
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM