I applied a custom font to a TextView
, but it doesn't seems to change the typeface.
Here is my code:
Typeface myTypeface = Typeface.createFromAsset(getAssets(), "fonts/myFont.ttf");
TextView myTextView = (TextView)findViewById(R.id.myTextView);
myTextView.setTypeface(myTypeface);
Can anyone please get me out of this issue?
Well, after seven years you can change whole app
textView
or what you want easily by usingandroid.support
libraries 26++.E.g:
Create your font package app/src/res/font and move your font into it.
And in your app theme just add it as a fontFamily:
Example for use with
textView
only:And add into your main theme:
Currently it's worked on 8.1 until 4.1 API Jelly Bean And that's a wide range.
I had the same problem, the TTF did not show up. I changed the font file, and with the same code it's working.
Yes, downloadable fonts are so easy, as Dipali s said.
This is how you do it...
TextView
.fontFamily
dropdown. If it isn't there, find the caret thingy (the > and click on it to expandtextAppearance
) under the.font-family
drop down.more fonts
Google Fonts
Add font to project
BONUS: If you would like to style EVERYTHING with text in your application with chosen font, just add
<item name="android:fontfamily">@font/fontnamehere</item>
into yourstyles.xml