Android - Using Custom Font

后端 未结 21 2090
别跟我提以往
别跟我提以往 2020-11-22 04:38

I applied a custom font to a TextView, but it doesn\'t seems to change the typeface.

Here is my code:

    Typeface myTypeface = Typeface         


        
21条回答
  •  暖寄归人
    2020-11-22 05:13

    After trying most of the solutions described in this thread, I accidentally found Calligraphy (https://github.com/chrisjenx/Calligraphy) - a library by Christopher Jenkins that lets you easily add custom fonts to your app. The advantages of his lib comparing to approaches suggested here are:

    1. you don't have to introduce your own overriden TextView component, you use the built-in TextView
    2. you can easily include the library using gradle
    3. The library doesn't limit your choice of fonts; you just add your preferred ones to the assets dir
    4. you not only get custom text views — all the other text-based Android compontents will also be displayed using your custom font.

提交回复
热议问题