【问题标题】:Custom attribute not resolved inside styles and theme自定义属性未在样式和主题中解析
【发布时间】:2019-11-28 14:45:05
【问题描述】:

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

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

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

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

当我要签署我的应用程序时,它会检查错误和提示:

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

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

这段代码直到 2 年前都在工作,当我将应用程序迁移到最新的 android SDK 工具 Gradle 和 androidX 时,最终出现了这个错误,我不知道出了什么问题。

我确实看到了这个answerthis one,但我找不到问题所在。

我还检查了thisthis,它们看起来更相关,但我没有意识到如何修复错误。

【问题讨论】:

    标签: android gradle android-theme android-styles android-attributes


    【解决方案1】:

    替换这个

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

    有了这个

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多