Android Lollipop中的Monospace发生了什么? [英] What's happened to Monospace in Android Lollipop?

查看:101
本文介绍了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-lightsans-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>

这篇关于Android Lollipop中的Monospace发生了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆