Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using custom Textview in Style

I have one custom TextView whose name is TextViewPlus. I want to add style for my custom TextView. when i write this to styles.xml it hasn't work. The error is :

error: Error: No resource found that matches the given name: attr 'foo:customFont'.

this is styles.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources
    xmlns:foo="http://schemas.android.com/apk/res/com.example">

    <style name="textstyle" parent="@android:style/TextAppearance">
        <item name="android:textSize">50sp</item>
        <item name="foo:customFont">Fonts/BZar.ttf</item>
    </style>
</resources>

Notice that I get my custom TextView from Custom fonts and XML layouts (Android)

like image 999
Hosein Bitaraf Avatar asked Nov 04 '22 03:11

Hosein Bitaraf


1 Answers

I resolve this issue by delete the namespace tag. change:

<style name="textstyle" parent="@android:style/TextAppearance">
    <item name="android:textSize">50sp</item>
    <item name="foo:customFont">Fonts/BZar.ttf</item>
</style>

to:

<style name="textstyle" parent="@android:style/TextAppearance">
    <item name="android:textSize">50sp</item>
    <item name="customFont">Fonts/BZar.ttf</item>
</style>
like image 176
mrz Avatar answered Nov 14 '22 23:11

mrz