Scroll not working for multiple RecyclerView in BottomSheet

前端 未结 6 721
天命终不由人
天命终不由人 2020-12-14 09:04

I implemented BottomSheet using the DialogFragment approach. I have a TabLayout and ViewPager in the BottomSheet

6条回答
  •  情歌与酒
    2020-12-14 09:41

    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.

    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

    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" }
    }
    

    Add the library to the dependencies:

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

    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);
        }
    }
    

提交回复
热议问题