Android O:新的字体目录和用法

时间:2017-05-29 11:40:22

标签: android

我根据本指南实现了XML功能中的新Android O字体:https://developer.android.com/preview/features/working-with-fonts.html

我已创建InetSocketAddress目录并添加了我的4个字体文件并创建了字体资源文件font

newfont.xml

现在我已经将字体系列添加到我的风格中:

<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android">
    <font
        android:fontStyle="regular"
        android:font="@font/NewFont_Rg" />
    <font
        android:fontStyle="medium"
        android:font="@font/NewFont_Md" />
    <font
        android:fontStyle="bold"
        android:font="@font/NewFont_Bd" />
    <font
        android:fontStyle="condensed"
        android:font="@font/NewFont_Cd" />
</font-family>

问题是,如何在样式中指定 使用哪种字体样式? <style name="HeadlineBig"> <item name="android:textSize">84sp</item> <item name="android:textColor">@color/body</item> <item name="android:fontFamily">@font/newfont</item> </style> regularmediumbold ...

1 个答案:

答案 0 :(得分:1)

风格将是

<item name="android:fontFamily">@font/NewFont_Rg</item>

<item name="android:fontFamily">@font/NewFont_Md</item>

<item name="android:fontFamily">@font/NewFont_Bd</item>