How to use specified weights for fonts in XML

后端 未结 9 2084
小蘑菇
小蘑菇 2021-01-30 02:58

Using the Fonts in XML feature you can specify various font weights for a font family. For example:



        
9条回答
  •  旧巷少年郎
    2021-01-30 03:46

    Step 1: Find or Download your font, let's say cavier_dream

    Step 2: Right-click on the res folder and create the font resource folder inside the res folder

    Step 3: Right-click on font folder and create a font resource file, let's say app_font.xml

    Step 4: Open the app_font.xml file and modify as follows

    
    

    
    

    Usage:

    For global usage across the application go to the styles.xml and inside the theme, create a new item as follow

     
    

    And for local usage simply use the fontFamily attribute and set the app_font as value.

    Happy coding:)

提交回复
热议问题