If have a TabLayout setup with a ViewPager and I use custom views for the tabs. Each custom view is a simple FrameLayout containing an ImageView with the appropriate states (different drawables for selected, pressed etc). The issue only happens at the beginning. The ImageView of the first tab is not selected although the ViewPager's current item is item 0. The problem disappears when tapping on the other tabs, so it's just an initialization issue. Is it an android issue? Is there a workaround? I tried invalidating the View but nothing seems to work.
Asked
Active
Viewed 2,019 times
1
-
1can you upload your code. what have you done? than it will be easy to capture bug. – Aiyaz Parmar Sep 18 '15 at 07:54
1 Answers
1
Use this code on onCreate() after setupWithViewPager() method is called.
mTabLayout.getTabAt(1).select();
mTabLayout.getTabAt(0).select();

Myat Min Soe
- 787
- 8
- 32
-
this helps me solve my problem! Thanks. But it's kinda weird why you have to select other index – Nov 19 '15 at 06:16