Wednesday, 9 January 2013

External Fonts in Android

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





No comments:

Post a Comment

Android SQLite Database Viewer or Debuging with Stetho

Every Android Developer uses SQLite Database to store data into the Android Application data. But to view the data in SQLite have a lot of...