Closed XuEnhao closed 6 years ago
参数是不是传错了,第一个是滚动到的目标Tab的下标,第二个是偏移量
tabLayout.setupWithViewPager(viewPager); tabLayout.setScrollPosition(position,position,true); viewPager.setCurrentItem(position); 还是没有显示在屏幕中
tabLayout.getSelectedTabPosition():这个位置是正确的 但是就是没有滚动到屏幕中间
总数是14个 在34567的时候 会缓缓偏移出屏幕 在后边整个就没了
第二个参数传0
final int roundedPosition = Math.round(position + positionOffset); if (roundedPosition < 0 || roundedPosition >= mTabStrip.getChildCount()) { return; } 我看源码 我如果点击的是最后一个 因为他是大于等于 childcount 直接return掉了?
那肯定return了,没有找到对应Position的Tab
总数15 在我点击第7个时已经跑出屏幕外了
看下您的网易邮箱 发邮件了 能详细说下吗
我测试过是没问题的 你再检查一下参数是否正确吧
我不做操作 直接viewpager.setcurritem 在第7个的时候就已经不在屏幕内了 title比较长
我看demo中 什么操作都没有做
进页面的时候 就直接setcurrtitem 数值越大偏移的越多 然后就出现了 偏移屏幕的问题
还是用的原生解决的 偏移问题
tabLayout.setScrollPosition(0,tabLayout.getSelectedTabPosition(),true); 找到了这个方法 但是好像没什么用