Java 自定义主题不工作

Java 自定义主题不工作,java,android,Java,Android,我已经阅读了创建样式的指南,我在style.xml中创建了它,如下所示 我已经导入了一个自定义图像,并将其添加到mainfest android:theme=“@style/CustomTheme”中,但当我启动应用程序时,它仍然不会显示我的主题 这是我的style.xml <resources> <!-- Application theme. --> <color name="custom_theme_color">#b0b0ff</color>

我已经阅读了创建样式的指南,我在style.xml中创建了它,如下所示

我已经导入了一个自定义图像,并将其添加到mainfest android:theme=“@style/CustomTheme”中,但当我启动应用程序时,它仍然不会显示我的主题

这是我的
style.xml

<resources>

<!-- Application theme. -->
<color name="custom_theme_color">#b0b0ff</color>
<style name="CustomTheme" parent="android:Theme.Light">
<item name="android:windowBackground">@drawable/images</item>
<item name="android:colorBackground">@drawable/images</item>
</style>

</resources>

#b0b0ff
@可绘图/图像
@可绘图/图像
这是我的主要文件

     <?xml version="1.0" encoding="utf-8"?>
     <manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="imamalsajadsayings.android.com"
      android:versionCode="2"
      android:versionName="1.1">
     <uses-sdk android:minSdkVersion="1"
          android:targetSdkVersion="19" />

   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
  <uses-permission android:name="android.permission.INTERNET"/> 

<application android:icon="@drawable/ic_launcher"
             android:allowBackup="true"
             android:theme="@style/CustomTheme" > 


     <activity android:name="imamalsajadsayings.android.com.MainActivity"
              android:label="@string/app_name"
              android:theme="@style/CustomTheme"> 
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
       </activity>
      <activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />”
  </application>

   </manifest>

好吧,这个主题不包括在内

<color name="custom_theme_color">#b0b0ff</color>
<style name="CustomTheme" parent="android:Theme.Light">
#b0b0ff
应该是这样:

<style name="CustomTheme" parent="android:Theme.Light">
<color name="custom_theme_color">#b0b0ff</color>

#b0b0ff
另外,如果您为应用程序设置了主题,则不需要为活动也设置主题


除非不同的活动有不同的主题(因此,您只能在这些活动上指定不同的主题)

这可能是问题所在:

您正在添加可绘制图形作为颜色资源

<item name="android:colorBackground">@drawable/images</item>
@drawable/images
这应该包含颜色值或颜色资源,如

<item name="android:colorBackground">#ffffff</item>
#ffffff

@color/自定义主题\u颜色

您可以通过调用
Activity.getTheme().dump()
活动中检查主题。

这样,您将知道到底出了什么问题(可能应用了主题,但窗口背景隐藏在容器视图的背景可绘制下)。我不明白为什么这个主题不适用

实际上OPs的方式是正确的,声明的颜色现在是一个应用程序资源,可以在任何地方使用。
<item name="android:colorBackground">@color/custom_theme_color</item>