Open rahul01 opened 7 years ago
I just found why, because Tab is added after calligraphy injected and apply font, and not sure TabLayout not referencing the typeface when adding Tab If your tab is added dynamically like my case, this is the only solution i have, you can refer my code, it is improved and cleaner version from your link, applicable for activity, but dynamic view like recycler view need to apply for the newly added view.
Picture for your reference, u can see the 3rd tab is not apply typeface after i call apply root view
protected void apply(ViewGroup vg)
{
Typeface type = Typeface.createFromAsset(getApplicationContext().getAssets(), "fonts/oxygen_light.ttf");
for(int i = 0; i < vg.getChildCount(); ++i)
{
View v = vg.getChildAt(i);
if(v instanceof TextView)
((TextView) v).setTypeface(type);
else if(v instanceof ViewGroup)
apply((ViewGroup) v);
}
}
You can do this in activity root view
setContentView(R.layout.activity_main);
apply((ViewGroup) findViewById(android.R.id.content));
@xeon90 : works great, however still looking for its support from the library.
@xeon90 works great. This solution works for tabitems added in xml file too. :+1:
Esta solução funciona muito. Muito obrigado.
Hi, issue still present. Any solution?
Want to use with
tabTextAppearance
attributelike this:
in styles:
in layout:
don't want to to this: ##http://stackoverflow.com/a/39252162/1529129