How to change fontFamily of TextView in Android

后端 未结 30 3128
感动是毒
感动是毒 2020-11-22 01:05

So I\'d like to change the android:fontFamily in Android but I don\'t see any pre-defined fonts in Android. How do I select one of the pre-defined ones? I don\'

30条回答
  •  忘掉有多难
    2020-11-22 01:45

    Here is an easier way that can work in some cases. The principle is to add a not visible TextVview in your xml layout and to get its typeFace in the java code.

    The layout in the xml file:

     
    

    And the java code:

    myText.setTypeface(textViewSelectedDescription.getTypeface());
    

    It has worked for me (within a TextSwitcher for example).

提交回复
热议问题