What happened to Monospace in Android Lollipop?

I have a "monospace" usage style 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> 

Everything was in order until Lollipop appeared, when it will no longer use the Monospace font, and I see how it changes when I transfer the API from 19 to 21 in Android Studio.

I searched googled and found nothing, and I appreciate that this is just a cosmetic problem, but does anyone have any ideas as to why?

+7
android android-5.0-lollipop monospace
source share
1 answer

Representations of the text of the material indicate the attribute android:fontFamily , and not android:typeface , so that they can use sans-serif-light , sans-serif-medium , etc. This attribute takes precedence over the font, so you need to either override or clear the fontFamily value.

 <style name="MenuText"> <item name="android:fontFamily">monospace</item> ... </style> 
+21
source share

All Articles