Titles In Tablayout Aren't Visible
Working with TabLayout Problem is Titles aren't visible i overide getPageTitle in adapter also i returned a string which would be title but that string doesn't show up. I have debu
Solution 1:
In my case I solved this by replacing,
tabLayout.setupWithViewPager(viewPager);
By,
viewPager.addOnPageChangeListener(newTabLayout.TabLayoutOnPageChangeListener(
                        tabLayout));
tabLayout.setOnTabSelectedListener(newTabLayout.OnTabSelectedListener() {
            @OverridepublicvoidonTabSelected(TabLayout.Tab tab) {
                viewPager.setCurrentItem(tab.getPosition());
            }
            @OverridepublicvoidonTabUnselected(TabLayout.Tab tab) {
            }
            @OverridepublicvoidonTabReselected(TabLayout.Tab tab) {
            }
});
I hope this will help you out.
Solution 2:
I made following changes in tablayout xml then titles were visible
 <android.support.design.widget.TabLayout
            android:id="@+id/tab"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabTextColor="#fff"
            app:tabGravity="fill"
            app:tabMode="scrollable"
            >
Solution 3:
This will do Trick for you. Add your
Tab Layoutin Runnable.
tabLayout.post(newRunnable() {
    @Overridepublicvoidrun() {
        tabLayout.setupWithViewPager(viewPager);
    }
});
Solution 4:
In your styles:
<stylename="NavigationTabTextAppeareance"parent="TextAppearance.Design.Tab"><itemname="android:textColor">#ffffff</item><itemname="android:textStyle">bold</item></style>In your XML:
 <android.support.design.widget.TabLayout
                android:id="@+id/tabs"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:layout_gravity="bottom"
                app:tabMode="scrollable"
                app:tabGravity="center"
                app:tabIndicatorHeight="4dip"
                app:tabTextAppearance="@style/NavigationTabTextAppeareance"
                app:tabIndicatorColor="#ffffff" />
Post a Comment for "Titles In Tablayout Aren't Visible"