【问题标题】:Titanium/Appcelerator: Cannot find Android themeTitanium/Appcelerator:找不到 Android 主题
【发布时间】:2017-01-19 08:38:56
【问题描述】:

我正在使用 Titanium/Appcelerator 构建一个 Android 应用程序,我正在关注他们的 guide on Android themes。根据指南,要使用默认 Android 主题之一,您必须:

  1. platform/android/res/values/ 中创建主题 XML 文件
  2. 插入他们的演示 XML 以启用默认 Android 主题
  3. TiApp.xml文件中设置主题

我已经这样做了,但是在尝试构建时出现错误:

错误:找不到与给定名称匹配的资源(在“主题”处,值为“@style/Light”)。

我注意到我在上述目录结构中创建的主题 XML 文件也消失了。为什么是这样?我怎样才能让主题发挥作用?

【问题讨论】:

  • 提供更多信息,例如您放置主题文件的文件夹结构。以及您在其中设置的主题名称。

标签: android titanium appcelerator


【解决方案1】:

您似乎将主题文件放在合金生成的文件夹中,这些文件夹在每次构建时都会被清理。

主题文件的正确结构是这样的:

注意 app - platform - android - res - values 文件夹中的 themes.xml 文件。

这可能是您的 themes.xml 文件的演示内容

<?xml version="1.0" encoding="utf-8"?>

<resources xmlns:android="http://schemas.android.com/apk/res/android">

    <style name="CustomTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">

        <item name="colorPrimary">#ff0000</item>

        <item name="colorAccent">#00ff00</item>

    </style>

</resources>

现在您的主题名称为 CustomTheme,因此您可以在 tiapp.xml 文件中设置此名称,如下所示:

<android xmlns:android="http://schemas.android.com/apk/res/android">
    <manifest>
        <application android:theme="@style/CustomTheme">

        </application>
    </manifest>
</android>

【讨论】:

  • 感谢您提供目录结构的屏幕截图——它让事情更清晰
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多