Closed necipallef closed 8 years ago
You have to setCustomView in your TabLayout.
In my case, I use TabLayout
( android.support.design.widget
).
I had same problem like you.
I made LayoutUtils
for apply CustomFontTab.
This is my code.
You can apply this code to your SlidingTabLayout
public class LayoutUtil {
public static void applyFontedTab(Activity activity, ViewPager viewPager, TabLayout tabLayout ) {
for (int i = 0; i < viewPager.getAdapter().getCount(); i++) {
TextView tv = (TextView) activity.getLayoutInflater().inflate(R.layout.view_item_tablayout, null);
if (i == viewPager.getCurrentItem()) tv.setSelected(true);
tv.setText(viewPager.getAdapter().getPageTitle(i));
tabLayout.getTabAt(i).setCustomView(tv);
}
}
}
I was using FragmentPagerAdapter and FragmentManager for tabs in the ViewPager, you are suggesting to switch to using TabLayout? I'd be happier if I didn't have to change the structure, cause I am not sure what is the difference between two.
I saw setCustomTabView()
in SlidingTabLayout class.
you can use setCustomTabView()
instead of my code
Using setCustomTabView()
and removing tabTitleView.setTypeface(null, Typeface.BOLD);
line inside SlidingTabLayout$populateStrip()
method worked. Thank you.
I am using SlidingTabLayout* and each page's title remains the same, while other views in the layout changes according to TypeKit settings.
*for SlidingTabLayout, please refer to link: http://developer.android.com/samples/SlidingTabsBasic/src/com.example.android.common/view/SlidingTabLayout.html