How To Change The Font Styles And Face In Android?
Solution 1:
in android only five fonttype-face
TypeFace
Typeface.DEFAULT
Typeface.MONOSPACE
Typeface.SANS_SERIF
Typeface.DEFAULT_BOLD
Typeface.SERIF
and font-type
Typeface.NORMAL
Typeface.BOLD
Typeface.BOLD_ITALIC
Typeface.ITALIC
you can use like as
textView.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
and other way is you can download any .ttf file
and put it in asset folder and use like as this
Typefacetype=Typeface.createFromAsset(context.getAssets(),
"DroidSansMono.ttf");
textView.setTypeface(type, null);
Solution 2:
You can change the font style and font face in your XML files. For example if you want to change your Button's style and face. Choose your button in xml and follow the below methods :
Button -> Right Click -> Properties -> Typeface and style
Hope this will help you.
Solution 3:
If you want to change in code ;
This is good reference;
http://mobile.tutsplus.com/tutorials/android/customize-android-fonts/
Solution 4:
what you want?. Do you want to change the font face and styles of text in textview. if yes then use this
Typefacetype = Typeface.createFromAsset(this.getAssets(),"your font name");
text.setTypeface(type);
and for styles use these links:
Solution 5:
If you want to use a font which is not default (like "Helvetica") for the text in Android application then put the font file(Helvetic.ttf) in assets folder and do use this code as below:
Typeface tf= Typeface.createFromAsset(getAssets(), "Helvetica.ttf");
TextViewmTextView=(TextView) findViewById(R.id.text);
mTextView.setTypeface(tf);
Post a Comment for "How To Change The Font Styles And Face In Android?"