TabLayout with viewpager not smooth scrolling

前端 未结 9 720
既然无缘
既然无缘 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:40

    I think you need to use override method setUserVisibleHint.

    You need to add this in your Fragment.

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        if (isVisibleToUser) {
            // load data here
        }else{
           // fragment is no longer visible
        }
    }
    

    Make your offScreenPageLimit to NUMBER OF TABS you have.

    Read more about setUserVisibleHint here.

提交回复
热议问题