RSS

Set custom font in android

19 Jan

Put your font in asset folder and access it from there as shown below:

public static void setCustomFontLight(Context context, View view){
 Typeface tf = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Light.ttf");
 if (view instanceof TextView) {
 ((TextView)view).setTypeface(tf);
 }
 else if (view instanceof Button) {
 ((Button)view).setTypeface(tf);
 }
 else if (view instanceof CheckBox) {
 ((CheckBox)view).setTypeface(tf);
 }
 }
Advertisements
 
Leave a comment

Posted by on January 19, 2013 in Android User Interface

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: