Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android custom font for tabs

I would like to have a custom font for my tabs. Here's what I have tried:

<style name="CustomTabWidgetText" 
parent="@android:style/TextAppearance.Widget.TabWidget">
  <item name="android:textSize">14sp</item>
  <item name="android:typeface">@assets/fonts/heartbre</item>
  <item name="android:textStyle">bold</item>
</style>

But I got an error in <item name="android:typeface">@assets/fonts/heartbre</item>.

Has anybody here tried customizing the font of tabs?


1 Answers

The only (currently) available way to set Fonts is to do it programatically:

TextView tv= (TextView)findViewById(R.id.custom);
Typeface face=Typeface.createFromAsset(getAssets(), "fonts/heartbre.ttf");
tv.setTypeface(face);

However, I hope there will be a xml-way to do it some day!

like image 93
poitroae Avatar answered Mar 11 '26 08:03

poitroae



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!