我根据本指南实现了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>
,regular
,medium
或bold
...
答案 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>