2

在我的清单中,应用程序主题指向 styles.xml 文件中列出的 android 样式:

<manifest 
xmlns:android="http://schemas.android.com/apk/res/android"
package="test.theme"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="16"
    android:targetSdkVersion="15" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/title_activity_main" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

样式.xml:

<resources>
    <style name="AppTheme" parent="android:Theme.Black" />
</resources>

但由于某种原因,无法识别主题,而是加载了白色主题。然而,当我像这样将主题直接放入清单时,它会按预期运行:

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.Black" >

即使在一个空的默认项目中也会出现同样的问题。值 AppTheme 列在 R.java 中,因此可以正常识别文件。有没有人有任何其他想法可能是什么问题?

4

1 回答 1

2

我最终确实解决了这个问题,最终它是一个非常简单的问题。

有一个特定于平台的 values-v14/styles.xml 文件,我应该将我的样式放入其中,因为此表中的默认值优先于我对全局 values/styles.xml 文件所做的更改。

因此,如果有人在这里遇到同样的问题,您可能需要检查是否为您的目标平台保存了正确的 styles.xml 文件。

于 2012-11-24T17:32:49.087 回答