material-components-android icon indicating copy to clipboard operation
material-components-android copied to clipboard

BottomSheetBehavior.findScrollingChild error with viewpager

Open zhuantou233 opened this issue 6 years ago • 4 comments
trafficstars

We're transitioning from github issues to a public buganizer component. Rather than submitting a bug here on github, please file any bugs or feature requests at https://issuetracker.google.com/issues/new?component=439535.

error link

Because of BottomSheetBehavior.findScrollingChild, if I use BottomSheetDialog with ViewPager, the second or more Fragment can't scroll.

The solution in the link will create new behavior not extend BottomSheetBehavior, which is not so elegant and will add new dialog or dialogfragment.

Hope it will be solved.

zhuantou233 avatar May 22 '19 10:05 zhuantou233

Hi! Could you please provide your code and more explanation as to your desired result?

melaniegoetz avatar May 29 '19 21:05 melaniegoetz

Hi! Could you please provide your code and more explanation as to your desired result?

https://github.com/choongyouqi/bottomsheet and the error gif is in the error link: https://stackoverflow.com/questions/39326321/scroll-not-working-for-multiple-recyclerview-in-bottomsheet?noredirect=1&lq=1

Actual result: When using BottomSheetDialog and ViewPager with 2 more fragment, and each fragment contains RecyclerView, only one fragment recyclerview can scroll while the other can't scroll. This error comes from BottomSheetBehavior.findScrollingChild

private View findScrollingChild(View view) {
   if (view instanceof NestedScrollingChild) {
       return view;
   }
   if (view instanceof ViewGroup) {
       ViewGroup group = (ViewGroup) view;
       for (int i = 0, count = group.getChildCount(); i < count; i++) {
           View scrollingChild = findScrollingChild(group.getChildAt(i));
           if (scrollingChild != null) {
               return scrollingChild;
           }
       }
   }
   return null;
}

Expected result: We want each RecyclerView fragment could scroll normally without define a new BottomSheetBehavior

zhuantou233 avatar May 30 '19 02:05 zhuantou233

Any updates on this? The linked SO question is over six years old!

MuntashirAkon avatar Jul 06 '22 16:07 MuntashirAkon