滚动不适用于BottomSheet中的多个RecyclerView [英] Scroll not working for multiple RecyclerView in BottomSheet

查看:700
本文介绍了滚动不适用于BottomSheet中的多个RecyclerView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用DialogFragment方法实现了BottomSheet.我在BottomSheet中有一个TabLayoutViewPager. ViewPager托管2个页面,每个页面都增加一个RecyclerView.第一个(咖啡"选项卡)RecyclerView滚动良好.我现在遇到的问题是,对于第二个(牛奶"选项卡),滚动无法正常工作.知道如何解决这个问题吗?谢谢!

I implemented BottomSheet using the DialogFragment approach. I have a TabLayout and ViewPager in the BottomSheet. The ViewPager is hosting 2 pages, each inflates a RecyclerView. The first(Coffee tab) RecyclerView scrolls fine. The problem I'm having now is that for the 2nd(Milk tab) the scroll is not working. Any idea how can I fix this? Thanks!

您可以在这里创建的演示项目中进行测试: https://github.com/choongyouqi/bottomsheet `

You can test out with the demo project I created here: https://github.com/choongyouqi/bottomsheet`

推荐答案

正如R.Zagórski所述,我描述了这种滚动行为的原因

As mentioned by R. Zagórski, I described the reason for this scrolling behavior here, i.e., BottomSheetBehavior only supports one scrolling child. However this answer wasn't focusing on Bottom Sheet Dialogs.

因此,就像R.Zagórski一样,我扩展了自己的,它克服了这一限制. 从 0.0.3 开始,支持底部对话框"!您可以在此处找到该库和示例应用程序: https://github.com/laenger/ViewPagerBottomSheet

Therefore – just like R. Zagórski – I extended my own library that overcomes this limitation. Starting with 0.0.3 there is support for Bottom Sheet Dialogs! You can find the library and the example app here: https://github.com/laenger/ViewPagerBottomSheet

要在您的项目中使用,只需将Maven存储库URL添加到build.gradle:

To use in your project, simply add the maven repo url to your build.gradle:

repositories {
    maven { url "https://raw.github.com/laenger/maven-releases/master/releases" }
}

将库添加到依赖项中:

dependencies {
    compile "biz.laenger.android:vpbs:0.0.3"
}

ViewPagerBottomSheetDialogFragment用作对话框片段的超类.然后在内容视图内设置任何ViewPager:

Use ViewPagerBottomSheetDialogFragment as super class for Dialog Fragments. Then setup any ViewPager inside the content view:

public class DialogFragment extends ViewPagerBottomSheetDialogFragment {
    @Override
    public void setupDialog(Dialog dialog, int style) {
        super.setupDialog(dialog, style);
        final View contentView = View.inflate(getContext(), R.layout.dialog_bottom_sheet, null);

        final ViewPager viewPager = (ViewPager) contentView.findViewById(R.id.viewpager);
        // ...
        BottomSheetUtils.setupViewPager(viewPager);

        dialog.setContentView(contentView);
    }
}

这篇关于滚动不适用于BottomSheet中的多个RecyclerView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆