I want to set margin in between each tab. Like in PagerTabStrip which has setTextSpacing(int textSpacing) to make text spacing between tab. Can TabLayout do that?
You can change the font family for selected/unselected tab only programmatically. You can listen which Tab is selected and unselected with TabLayout. OnTabSelectedListener and on onTabSelected(TabLayout. Tab tab) callback you can change the Typeface for the selected Tab and on onTabUnselected(TabLayout.
Android ViewPager ViewPager with TabLayout A TabLayout can be used for easier navigation. You can set the tabs for each fragment in your adapter by using TabLayout. newTab() method but there is another more convenient and easier method for this task which is TabLayout. setupWithViewPager() .
Been fighting this problem for a while too, found the solution on this thread : Android Design Support Library TabLayout using custom tabs layout but layout wrapping the tabs
<!-- Add the padding to tabPaddingStart and/or tabPaddingEnd --> <android.support.design.widget.TabLayout android:id="@+id/tabLayout" android:layout_width="match_parent" android:layout_height="@dimen/tab_layout_height" app:tabPaddingStart="10dp" app:tabPaddingEnd="10dp">
You can use tabMinWidth attribute. like this.
<android.support.design.widget.TabLayout android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="44dp" app:tabIndicatorColor="@color/default_enable" app:tabTextColor="@color/font_default_03" app:tabSelectedTextColor="@color/default_enable" app:tabMinWidth="50dp" android:clipToPadding="false" android:paddingLeft="4dp" android:paddingRight="4dp" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With