How to use specified weights for fonts in XML

后端 未结 9 1992
小蘑菇
小蘑菇 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:52

    As pointed out by @FlorianWalther, the TextView.textFontWeight attribute is exactly what I was looking for. This attribute was apparently added in API level 28, but was not documented until recently.

    Make sure all of the weights are in the same XML file (as in my question), then simply use the attribute along with the fontFamily attribute.

    
    

    As far as I am aware this attribute is only available in API Level 28 an above, I will update if I find its counterpart in the support library.

提交回复
热议问题