Using TabLayout inside a Fragment; tab text invisible

前端 未结 5 1735
迷失自我
迷失自我 2020-12-08 03:00

I\'m currently experimenting with various new components in the new Android Support Design library. I\'ve implemented a NavigationView in my MainActivity.

5条回答
  •  被撕碎了的回忆
    2020-12-08 03:21

    The developer working on this library recommends the following work-a-round:

    if (ViewCompat.isLaidOut(tabLayout)) {
            tabLayout.setupWithViewPager(viewPager);
        } else {
            tabLayout.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
                @Override
                public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
                    tabLayout.setupWithViewPager(viewPager);
                    tabLayout.removeOnLayoutChangeListener(this);
                }
            });
        }
    

提交回复
热议问题