Titanium/Appcelerator:找不到Android主题

shr*_*ans 0 android titanium appcelerator

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

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

我已经完成了这个,但是在尝试构建时遇到错误:

错误:找不到与给定名称匹配的资源(在'theme'处,值为'@ style/Light').

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

Pra*_*ini 5

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

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

请注意位于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>
Run Code Online (Sandbox Code Playgroud)

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

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

        </application>
    </manifest>
</android>
Run Code Online (Sandbox Code Playgroud)