<?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 'typeface'。
我正在使用
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" />
最佳答案
The Typeface class specifies the typeface and intrinsic style of a font.
你应该调用 android:typeface
而不是 typeface
。
不要
<item name="typeface">robotoRegular</item>
做
<item name="android:typeface">robotoRegular</item>
关于java - 错误 : No resource found that matches the given name: attr 'typeface' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34940315/