2017-05-29 10 views
0

我根據這個指南在實現XML功能的新的AndroidØ字體:https://developer.android.com/preview/features/working-with-fonts.html的Android○:新的字體目錄和使用

我創建了font目錄,並添加我的4個字體文件並創建了一個字體資源文件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> 

現在我已經添加了字體系列我的風格:

​​3210

的問題是,如何我是否在風格中指定要使用哪種字體樣式? regularmediumboldcondensed ...

回答

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> 
+0

不幸的是我得到了許多錯誤關於我的字體(這些都沒有任何意義,因爲我一直在使用這些字體在編程上是'沒有錯誤的舊方式'),所以我想我會等待幾個月,直到此功能成熟。無論如何,你的回答可能是正確的。 – Ambran

+0

@Ambran它爲我工作。但直到現在代碼不能在工作中使用。所以,如果你需要,我可以分享你提供的谷歌相同的代碼,但有一些修改,使其正常運行。 –

+0

這將是偉大的,謝謝。 – Ambran