I want to embed custom font in tablayout from design support library. I try to set custom view which is set typeface already. But it is not working. Just appear system font.
What I did is,
mAdpater = new CustomPagerAdapter(getSupportFragmentManager());
mFragmentPager.setAdapter(mAdpater);
mTabs.setupWithViewPager(mFragmentPager);
Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/myFont.ttf");
for (int i = 0; i < mTabs.getTabCount(); i++) {
TextView tv = new TextView(this);
tv.setText(mAdpater.getPageTitle(i));
tv.setTypeface(tf);
mTabs.getTabAt(i).setCustomView(tv);
}
Welcome for any suggestion.
If you override
getPageTitle
in yourFragmentPagerAdapter
, then callthe tabs text is set for you.
Then to change the font I used this method from this SO post
Here is the
FragmentPagerAdapter
in its entirety for reference