I\'m defining a style XML for my android app. I have some TTF files I want to use, how can I set the typeface to use those files as the font as opposed to the generic \"san
Create a font dir on resource folder and paste your ttf font file. Then create a font resource XML and paste following lines.
Now you can apply font as below. Also note attribute 'textStyle'
If you want done from code use following, but minimum API level 26
Typeface typeface = getResources().getFont(R.font. roboto_light_italic);
textView.setTypeface(typeface);
The Support Library 26.0 provides support to the Fonts in XML feature on devices running Android 4.1 (API level 16) and higher.
Typeface typeface = ResourcesCompat.getFont(context, R.font. roboto_light_italic);