TabLayout with viewpager not smooth scrolling

前端 未结 9 680
既然无缘
既然无缘 2020-12-29 03:36

Edit

I have followed these tutorials to fix this problem.

http://www.truiton.com/2015/06/android-tabs-example-fragments-viewpager/ https://g

相关标签:
9条回答
  • 2020-12-29 03:51

    Please Set viewPager.setOffscreenPageLimit(1); to viewPager.setOffscreenPageLimit(5);

    0 讨论(0)
  • 2020-12-29 03:56

    This is nothing new with android's coordinate layout and appBar layout; I am sure you won't be able to make it smoother no matter what you do. However

    https://github.com/henrytao-me/smooth-app-bar-layout
    

    this could fulfill your requirements; However firstly download the sample app from

    https://play.google.com/store/apps/details?id=me.henrytao.smoothappbarlayout
    

    to see if it fits your need.(just to be sure)

    0 讨论(0)
  • 2020-12-29 03:57

    I just went through your code. The problem is that you are not providing any layout to inflate inside ContentFragment.java.

    I changed your method to

        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
            //return super.onCreateView(inflater, container, savedInstanceState);
            return  inflater.inflate(R.layout.feed_item, container, false);
    
        }
    

    After making these changes your tabs were scrolling smoothly. I don't know the reason behind this behaviour but this thing made it work

    0 讨论(0)
提交回复
热议问题