Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Arial font for text in Android

Tags:

android

fonts

I want to show text in Arial font. But Arial font is not available in android system fonts. I don't want to use arial ttf file in my application. Is there any other way to apply text with Arial font.

like image 581
jkstar Avatar asked Apr 24 '13 04:04

jkstar


2 Answers

If the font is not available in the android system, then you have to use the font file to apply that particular font say arial to your textView. May I know why you are not willing to use the font file to apply as it gives the same functionality.

Sample usage for using the font file is:

Typeface tfArial = Typeface.createFromAsset(getAssets(), "arial.ttf");
TextView tv = null;
// find the textview id from layout or create dynamically
tv.setTypeface(tfArial);

EDIT:

You need to put the font file arial.ttf in your asset folder.

like image 169
java dev Avatar answered Sep 20 '22 15:09

java dev


Download Arial font and in assets create folder name with "fonts" and save font at there

Typeface tf = Typeface.createFromAsset(getAssets(),"fonts/arial.ttf");
TextView tv = (TextView) findViewById(R.id.CustomFontText);
tv.setTypeface(tf);
like image 30
stackoverflow Avatar answered Sep 17 '22 15:09

stackoverflow