Android Typeface createFromAsset
You can use your View
's getContext()
method to get the current Context
, then use it to get the assets:
Typeface font = Typeface.createFromAsset(getContext().getAssets(), "robotobold.ttf");
First of all, you have to keep your assets
folder inside your project
and not inside src/main
.. And then, create a folder called fonts
inside assets
. then, put the specific font typeface ttf files
inside it.You can use the font typeface in coding like:
Typeface type = Typeface.createFromAsset(getAssets(),"fonts/filename.ttf");
textview.setTypeface(type);