4

I want to change the font of the tabs in PagerSlidingTabStrip this is how i try it but it has no effect.

MyPagerAdapter pagerAdapter = new MyPagerAdapter(getSupportFragmentManager());
    viewPager.setAdapter(pagerAdapter);
    pagerSlidingTabStrip.setViewPager(viewPager);
    pagerSlidingTabStrip.setTextColor(getResources().getColor(R.color.white));
    pagerSlidingTabStrip.setTypeface(Typeface.createFromAsset(getAssets(), getString(R.string.ronney_sans_regular_font)), Typeface.NORMAL);
    pagerSlidingTabStrip.setIndicatorColor(getResources().getColor(R.color.second_primary_color));
AdrianoCelentano
  • 2,461
  • 3
  • 31
  • 42
  • 1
    Do the text color and the indicator color get changed? – LukaCiko Feb 04 '15 at 21:01
  • yes all the other stuff is working, i also checked the code in the library after for example setIndicatorColor() the same update method gets called like for setTypeface() – AdrianoCelentano Feb 04 '15 at 21:06
  • 1
    I'm setting up a PagerSlidingTabStrip in my project and the font does get changed. Does the getString method return the right string? Is your font in the assets folder? If your font is e.g. in src/main/assets/fonts folder, then the string should be `fonts/.ttf` and not `assets/fonts`... – LukaCiko Feb 04 '15 at 21:32
  • sry was my fault (surprise) the new font just looked almost the sam like the original one ... – AdrianoCelentano Feb 05 '15 at 02:53

1 Answers1

0

if you use this library :

https://github.com/jpardogo/PagerSlidingTabStrip

in PagerSlidingTabStrip class change line 185 :

mTabTextTypeface = Typeface.create(tabTextTypefaceName, mTabTextTypefaceStyle);

to this :

mTabTextTypeface = Typeface.create(Typeface.createFromAsset(context.getAssets(),"DroidNaskh.ttf"), mTabTextTypefaceStyle);
Hamid Zandi
  • 2,714
  • 24
  • 32