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!
You can test out with the demo project I created here: https://github.com/choongyouqi/bottomsheet`
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); } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With