2016-01-22 82 views
5
<?xml version="1.0" encoding="utf-8"?> 
<resources xmlns:android="http://schemas.android.com/apk/res/android"> 

    <style name="TextViewAppearance" parent="@android:style/TextAppearance.Widget.TextView"> 
     <item name="android:layout_width">wrap_content</item> 
     <item name="android:layout_height">wrap_content</item> 
     <item name="typeface">robotoRegular</item>    
    </style> 

    <style name="TextViewAppearance.Display1" parent="@style/TextViewAppearance"> 
     <item name="typeface">robotoBlack</item> 
     <item name="android:textSize">45sp</item> 
     <item name="android:textColor">@color/main_color_grey_500</item> 
    </style> 
</resources> 

四處錯誤: 錯誤:(4,5)沒有資源發現在給定名稱匹配:ATTR「字樣」。錯誤:未發現的資源與給定名稱匹配:ATTR「字樣」

我使用
1. Android Studio中1.5.1
2的minSdkVersion 15
3. targetSdkVersion 23

< -----------編輯--- ------------------>

我的佈局文件是

<abcapp.com.font.RobotoTextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"    
       android:text="ABC"    
       android:textSize="16sp" 
       app:typeface="robotoBlack" /> 

回答

7

The Typeface class specifies the typeface and intrinsic style of a font.

你應該叫android:typeface而不是typeface

<item name="android:typeface">robotoRegular</item> 
+0

我在xml佈局文件中使用了「app:typeface」。我剛剛在我的問題中添加了xml佈局文件代碼 – Ali

+1

@smoke http://stackoverflow.com/questions/2973270/using-a-custom-typeface-in-android –

0

你應該使用android:typeface,不是typeface

+0

我使用的是不是

<item name="typeface">robotoRegular</item> 

做:在XML佈局文件 「應用字體」。我剛剛在我的問題中添加了xml佈局文件代碼 – Ali

+0

但是看起來你並沒有像'android'那樣聲明'app'標籤。 – starkshang

0

使用

<item name="android:typeface">YOUR FONT</item> 
+0

我在xml佈局文件中使用「app:typeface」。我剛剛在我的問題中添加了xml佈局文件代碼 – Ali

相關問題