Error: resource not found that matches the specified name: attr 'typeface'

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

Getting error: Error: (4, 5) A resource was not found that matches the specified name: attr 'typeface'.

I am using 1. Android Studio 1.5.1
2.minSdkVersion 15
3. targetSdkVersion 23

<----------- Change --------------------->

My layout file

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

The Typeface class specifies a font and a custom font style.

You should call android:typeface instead of typeface .

Not

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

Do

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

you should use android:typeface , not typeface .

+1
source

using

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

Source: https://habr.com/ru/post/1241197/


All Articles