如何获取当前在textview / edittext中使用的字体?我没有设置自定义字体,但需要知道android使用哪种字体向我显示textview中的文本:Noto,Roboto,Noto CJK或SansSerif Hebrew等。
你的问题没有错。如果你还没有使用过setTypeFace()
,你会将null
作为TextView
的默认TypeFace,或者Button
中定义style.xml
。就像是:
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:textViewStyle">@style/RobotoTextViewStyle</item>
<item name="android:buttonStyle">@style/RobotoButtonStyle</item>
</style>
<style name="RobotoTextViewStyle" parent="android:Widget.TextView">
<item name="android:fontFamily">sans-serif-light</item>
</style>
检查这个问题Default Font-Family for App,Default font
我自己尝试了,你是对的,它返回null
似乎是typeFace更改默认属性但是视图开始时的属性并不直接解释为typeFace
您是否尝试在更改它之前在getTypeface()
中调用TextView
并将结果存储在某处? Check this link, this will help you