How to change the Font styles and face in Android?

前端 未结 6 1478
不知归路
不知归路 2020-12-14 11:28

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 tha

相关标签:
6条回答
  • 2020-12-14 11:55

    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

    0 讨论(0)
  • 2020-12-14 11:55

    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);
    
    0 讨论(0)
  • 2020-12-14 11:57

    If you want to change in code ;

    This is good reference;

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

    0 讨论(0)
  • 2020-12-14 12:08

    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);
    
    0 讨论(0)
  • 2020-12-14 12:13

    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);
    
    0 讨论(0)
  • 2020-12-14 12:14

    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.

    0 讨论(0)
提交回复
热议问题