I want to use TabLayout
with TabItem
with following code:
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/color_primary"
app:tabGravity="fill"
app:tabIndicatorColor="@color/white"
app:tabMode="fixed"
app:tabSelectedTextColor="@color/white"
app:tabTextColor="@color/gray_light">
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:icon="@drawable/ic_language" />
<!-- other tabs ... -->
</android.support.design.widget.TabLayout>
And this is show me Icons correctly like this:
But the problem is when I want to add my TabLayout
to ViewPager
, with following code, all of them exist and clickable but disappear. Did I miss something?
MyPagerAdapter adapter = new MyPagerAdapter(getFragmentManager());
pager.setAdapter(adapter);
tabLayout.setupWithViewPager(pager);
and this is result: