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>

Getting Error: Error:(4, 5) No resource found that matches the given name: attr 'typeface'.

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

<----------- Edit --------------------->

My Layout file is

<abcapp.com.font.RobotoTextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"               
                android:text="ABC"               
                android:textSize="16sp"
                app:typeface="robotoBlack" />
Ali
  • 3,545
  • 11
  • 44
  • 63

3 Answers3

8

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

You should call android:typeface instead of typeface .

Don't

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

Do

<item name="android:typeface">robotoRegular</item>
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
1

you should use android:typeface,not typeface.

starkshang
  • 8,228
  • 6
  • 41
  • 52
0

use

<item name="android:typeface">YOUR FONT</item>
ErShani
  • 392
  • 2
  • 9
  • I'm using "app:typeface" in xml layout file. I have just added xml layout file code in my question – Ali Jan 22 '16 at 06:41