Praveenkumar
Praveenkumar

Reputation: 24476

How to change the Font styles and face in Android?

I want to change the font face and styles in android. How to do this? Am using emulator. Is this possible to change in emulator. Is there any permissions available to do that. Thanks in Advance.

Upvotes: 12

Views: 41596

Answers (6)

Niranj Patel
Niranj Patel

Reputation: 33238

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

Typeface type=Typeface.createFromAsset(context.getAssets(),
        "DroidSansMono.ttf");
textView.setTypeface(type, null);

Upvotes: 26

Bunny
Bunny

Reputation: 1064

if u want to use custom font jus download .ttf file and put the file into assets folder and use like this:

TextView tv=(TextView)findViewById(R.id.textView);
Typeface  tf = Typeface.createFromAsset(getActivity().getAssets(), "fonts/arial.ttf");
tv.setTypeface(tf);

Upvotes: 1

Subrat
Subrat

Reputation: 3988

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");
  TextView mTextView =(TextView) findViewById(R.id.text);
    mTextView.setTypeface(tf);

Upvotes: 1

kalpana c
kalpana c

Reputation: 2739

what you want?. Do you want to change the font face and styles of text in textview. if yes then use this

Typeface type = Typeface.createFromAsset(this.getAssets(),"your font name");
text.setTypeface(type);

and for styles use these links:

  1. Style-resource

  2. Themes

Upvotes: 2

Günay Gültekin
Günay Gültekin

Reputation: 4793

If you want to change in code ;

This is good reference;

http://mobile.tutsplus.com/tutorials/android/customize-android-fonts/

Upvotes: 3

sudhakar
sudhakar

Reputation: 41

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.

Upvotes: 4

Related Questions