Android Lollipop中的Monospace发生了什么?
我有一种样式可以在我的Android应用程序中使用等宽":
I have a style to use "monospace" in my Android App:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar" >
<!-- Customize your theme here. -->
<item name="android:windowNoTitle">true</item>
<item name="android:typeface">monospace</item>
<item name="android:textColorPrimary">@android:color/white</item>
<item name="android:itemTextAppearance">@style/MenuText</item>
</style>
<style name="M13Text">
<item name="android:typeface">monospace</item>
<item name="android:textColor">@android:color/white</item>
<item name="android:textColorLink">@android:color/holo_red_light</item>
</style>
<style name="MenuText">
<item name="android:typeface">monospace</item>
<item name="android:textColor">@android:color/black</item>
</style>
</resources>
一切都很好,直到Lollipop似乎不再使用Monospace字体为止,并且当我在Android Studio中将API从19转换为21时,可以看到它发生了变化.
All was fine until Lollipop arrived when it doesn't seem use the Monospace font anymore and I can see it change when I flip APIs from 19 to 21 in Android Studio.
我已经在Google上搜索并没有找到任何东西,我很欣赏这只是一个表面问题,但是任何人都对为什么有任何想法?
I've googled and not found anything and I appreciate it is just a cosmetic issue but anyone got any ideas as to why?
材料"文本外观指定android:fontFamily
属性而不是android:typeface
,以便它们可以使用sans-serif-light
,sans-serif-medium
等.此属性采用优先于字体,因此您将需要覆盖或清除fontFamily值.
The Material text appearances specify the android:fontFamily
attribute rather than android:typeface
so that they can use sans-serif-light
, sans-serif-medium
, etc. This attribute takes precedence over typeface, so you will need to either override or clear the fontFamily value.
<style name="MenuText">
<item name="android:fontFamily">monospace</item>
...
</style>