I need to show the 2nd page of viewPager. After

viewPager.setCurrentItem(1);

it really shows the 2nd page. BUT PagerSlidingTabStrip shows the 3rd page... And then if I scroll to any direction - tabs update itself and look/switch correct. And this problem I see only at Nexus-4, but not at the Nexus-5, HTC ONE and other devices...

有帮助吗?

解决方案

I've found the reason, why this is happening. In my code I added a margin to viewPager.

   final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources()
            .getDisplayMetrics());
   pager.setPageMargin(pageMargin);

And if you remove this margin - you will solve this problem particular. I don't have other ways

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top