Titanium/Appcelerator: 找不到 Android 主题

Titanium/Appcelerator: Cannot find Android theme

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

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

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

Error: No resource found that matches the given name (at 'theme' with value '@style/Light').

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

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

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

注意 themes.xml 文件位于 app - platform - android - res - values文件夹。

这可能是您的 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>