Android 在样式中使用自定义Textview

Android 在样式中使用自定义Textview,android,customization,textview,Android,Customization,Textview,我有一个自定义的TextView,它的名字是TextViewPlus。我想为我的自定义文本视图添加样式。当我把它写到styles.xml时,它就不起作用了。错误是: 错误:错误:未找到与给定名称匹配的资源:attr “foo:customFont” 这是styles.xml: <?xml version="1.0" encoding="utf-8"?> <resources xmlns:foo="http://schemas.android.com/apk/res/co

我有一个自定义的
TextView
,它的名字是
TextViewPlus
。我想为我的自定义
文本视图添加样式。当我把它写到
styles.xml
时,它就不起作用了。错误是:

错误:错误:未找到与给定名称匹配的资源:attr “foo:customFont”

这是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>

50便士
字体/BZar.ttf

注意,我从

获得了自定义文本视图。我通过删除名称空间标记来解决此问题。 更改:


50便士
字体/BZar.ttf
致:


50便士
字体/BZar.ttf

您是否为customFont创建了属性?请阅读本文,这可能会给您一些启示。我确实遇到了这个问题。有什么解决方案吗?
<style name="textstyle" parent="@android:style/TextAppearance">
    <item name="android:textSize">50sp</item>
    <item name="foo:customFont">Fonts/BZar.ttf</item>
</style>
<style name="textstyle" parent="@android:style/TextAppearance">
    <item name="android:textSize">50sp</item>
    <item name="customFont">Fonts/BZar.ttf</item>
</style>