ListView inside ViewPager won't scroll when applying a PageTransformer

前端 未结 3 1252
日久生厌
日久生厌 2020-12-18 14:12

I have a ViewPager in which the pages contain ListViews. Everything works fine and my viewPAger as well as ListViews work as expected : it is possible to swipe from page to

3条回答
  •  时光说笑
    2020-12-18 14:48

    I don't know if you got this working, but I have the same issue, with a PageDepthTransformer. I'm using a gridview though, the scrolling works, however my subsequent fragments seem to have focus and my top level Fragment doesn't register the correct onClick() events.

    My work around for this was to add global layout listener to viewPager and bring the current view to the front

    viewPager.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
    
        @Override
        public void onGlobalLayout() {
    
            View view = viewPager.getChildAt(currentFragmentPosition);
    
            if (view != null) {
                view.bringToFront();
            }
        }
    )};
    

    This seems like hackery to me, and I haven't quite got this working on rotation. But hopefully it might help you.

提交回复
热议问题