java - 错误 : No resource found that matches the given name: attr 'typeface'

标签 java android android-studio android-support-library

<?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/

相关文章:

java - IntelliJ IDEA新建项目时自动创建的文件和文件夹是什么

java - 如何检查 Scanner Util 的输入字符串是否与初始字符串匹配

java - Java 分布式应用程序健康监视器的框架?

java - 将生产 Android 应用程序从 Windows 7 正确移动/移植到基于 Linux 的系统

java - 创建按钮来调用特定号码 - Android Studio

java - Android Studio - 无法从预装的 sqlite 数据库检索数据

Java httpget 似乎可以工作,但遇到 401 错误

android - Android 地理围栏示例代码中的错误?任何人都可以确认吗?

android - dagger 中的 DI 和泛型类

java - 如何使用 Spinner 下拉菜单更改 TextView 小部件上的文本