自定义属性无法在样式和主题内解析 [英] Custom attribute not resolved inside styles and theme

查看:119
本文介绍了自定义属性无法在样式和主题内解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2-3年前开发的具有自定义主题的android应用程序. 我的attr.xml资源文件中有这个样式:

I have android application with custom themes which was developed 2-3 year ago. I had this stylable in my attr.xml resouce file:

<declare-styleable name="EVETextViewPlus">
    <attr name="customFont" format="string" />
    <attr name="pageStripFont" format="string" />
</declare-styleable>

我已经在我的style_warm.xml资源文件中使用了它:

And I've used this inside my style_warm.xml resource file:

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android"
    <style name="style_display_page_title_warm">
        <item name="my.app.package.:pageStripFont">fonts/b_titr.ttf</item>
        <item name="android:textSize">25dp</item>
        <item name="android:textColor">@color/colorDisplayPageTitle</item>
    </style>
....

当我要对我的应用进行签名时,它会检查错误并提示:

When I'm going to sign my app, it checks for errors and prompts:

无法解析符号"my.app.package:pageStripFont"

Cannot resolve symbol 'my.app.package:pageStripFont'

我应该提到my.app.package是清单中定义的应用程序的程序包名称.

I should mention my.app.package is package name of my application defined in manifest.

这是直到2年前都可以使用的代码,当我将应用程序迁移到最新的android SDK工具Gradle和androidX时,此错误最终出现了,我不知道怎么了.

This is piece of code which was working until 2 years ago and when I migrated my application to latest android SDK tools, Gradle and androidX, this error was eventually appeared and I don't know what's wrong.

我确实看到了这个答案

I did see this answer, this one but I could not find the problem.

我还检查了

I also checked this and this which see more revelant but I did not realize how to fix the error.

推荐答案

替换此

<item name="my.app.package.:pageStripFont">fonts/b_titr.ttf</item>

与此

<item name="pageStripFont">fonts/b_titr.ttf</item>

这篇关于自定义属性无法在样式和主题内解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆