Hey,
I don't want to use default android font(Roboto), how can I insert new font in android to use it in my app and how to use it?
Please help :)
- 5 years ago
You have to download your font .ttf file or .otf files and paste in your Assets folder in res->assets>fonts
Put your 'fontfile.ttf' into the fonts folder
where you want to use your customize font call something like below code
TextView textV = (TextView)findViewById(R.id.vbageTextView_ID);
Typeface vb_custom_font = Typeface.createFromAsset(getAssets(), "fonts/fontfile.ttf");
textV.setTypeface(vb_custom_font);
- 5 years ago
You have to download your font .ttf file or .otf files and paste in your Assets folder in res->assets>fonts
Put your 'fontfile.ttf' into the fonts folder
where you want to use your customize font call something like below code
TextView textV = (TextView)findViewById(R.id.vbageTextView_ID);
Typeface vb_custom_font = Typeface.createFromAsset(getAssets(), "fonts/fontfile.ttf");
textV.setTypeface(vb_custom_font);
- 5 years ago
Hi Vicky,
Thanks for your reply, can you please tell me where to put this code?
TextView textV = (TextView)findViewById(R.id.vbageTextView_ID); Typeface vb_custom_font = Typeface.createFromAsset(getAssets(), "fonts/fontfile.ttf"); textV.setTypeface(vb_custom_font);
- 5 years ago
Just follow below steps:
Go to res folder in app - right click on res >> select New > Android resource directory
>> Fill directory name as font and select Resourse type as font(from list) >> Click OK
>> Add your .ttf or .otf font files in font directory by simply copy your files and right click on font directory and select paste (just make sure not to use '-' in font file name)
>> Now just set your font family in textView where you want to use
android:fontFamily="@font/fontfileName
Or you can just go to design view in android studio - expend textAppearence and select your fontFamily there in properties and you can also modify other attributes in properties easily in design view.
Hot Questions