What is the difference between fontFamily and typeFace in android?

前端 未结 1 1880
生来不讨喜
生来不讨喜 2021-02-05 09:16

What is the difference between fontFamily and typeFace in android ? Of course, I read all the description in android developer site, but I\'m not clear yet.

According to

1条回答
  •  一生所求
    2021-02-05 09:51

    To find the answer of your question you have to look into the source code of TextView, you will find its implementation here

    https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/java/android/widget/TextView.java

    Now from the implementation of method setTypefaceFromAttrs() it seems like, If you have set fontFamily attribute then typeface attribute will be ignored.

    Also android:typeface attribute is added in api level 1 and using this you can set following fonts

    - normal
    - serif
    - sans
    - monospace
    

    Whereas android:fontFamily attribute is added in api level 16 and this supports more fonts from roboto font family like -

    - serif
    - monospace
    - sans-serif
    - sans-serif-condensed
    - serif-monospace
    - sans-serif-smallcaps
    

    For more information use below link

    Valid values for android:fontFamily and what they map to?

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