Here i explains example for using external fonts in Android View.
Android applications using external font files with .ttf extension we can change default font of Text.
Here I have downloaded ".ttf” file from google. Created a new folder “font” in assets folder and paste your recently downloaded font file.
Here we can change the font for a TextView simply using below code in your Activity.
String ttf_fontPath = "fonts/TIMES_SQ.TTF";
TextView textview = (TextView) findViewById(R.id.textview);
Typeface font = Typeface.createFromAsset(getApplicationContext().getAssets(), ttf_fontPath);
textview.setTypeface(font);
Screen Shots:
Here we can see we are created font folder under assert folder of your project
Final Output Screen Shot
Android applications using external font files with .ttf extension we can change default font of Text.
Here I have downloaded ".ttf” file from google. Created a new folder “font” in assets folder and paste your recently downloaded font file.
Here we can change the font for a TextView simply using below code in your Activity.
String ttf_fontPath = "fonts/TIMES_SQ.TTF";
TextView textview = (TextView) findViewById(R.id.textview);
Typeface font = Typeface.createFromAsset(getApplicationContext().getAssets(), ttf_fontPath);
textview.setTypeface(font);
Screen Shots:
Here we can see we are created font folder under assert folder of your project
Final Output Screen Shot
No comments:
Post a Comment