Android 清单中的更改主题不起作用

Android 清单中的更改主题不起作用,android,android-theme,Android,Android Theme,我在styles.xml中定义了两个主题 应用主题1和应用主题2: <resources> <!-- Base application theme. --> <style name="AppTheme1" parent="Theme.AppCompat.Light.NoActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@c

我在styles.xml中定义了两个主题 应用主题1和应用主题2:

<resources>

<!-- Base application theme. -->
<style name="AppTheme1" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme2" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">#00ff00</item>
    <item name="colorPrimaryDark">#ff00ff</item>
    <item name="colorAccent">#0000ff</item>
</style>
</resources>
当我在AndroidManifest.xml中更改应用程序标记中的主题时 我的应用程序主题没有任何变化,应用程序只使用colors.xml而不使用style.xml。 例如,我的清单文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.maneshtsoft.blackdictionary">

<application
    android:allowBackup="true"
    android:icon="@mipmap/favicondark"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme2">
    <!-- OR AppTheme1 does not matter -->
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

</manifest>
只是说我使用工具栏和AppCompactActivity可能有助于回答这个问题。
谢谢。

问题可能是InstantRun的缓存。
您是否尝试过清除并重新运行?如果您使用AndroidStudio 2.1或更高版本,请选择菜单->运行->清除并重新运行。

不要对第二个主题使用同一个父主题,而是使用theme.NoActionBari如果使用不同的父主题,则应用程序会因强制关闭而崩溃,logcat中的错误:原因:java.lang.IllegalStateException:此活动已具有由窗口装饰提供的操作栏。不要请求Window.FEATURE\u SUPPORT\u ACTION\u BAR,并在主题中将windowActionBar设置为false以使用工具栏。您基本上想要什么?如果您只想更改颜色并将该主题应用于应用程序,请删除AppTheme2并从res->values->colors.xml中打开colors.xml,只需更改将影响应用程序主题的颜色。告诉我,您希望实现什么?应用程序主题在运行时不会更改,但您可以通过使用setTheme来更改活动主题。SetContentView之前必须调用setTheme。我使用android studio 2.1.2并运行了它->清理&重新运行。但不是帮助,这很奇怪。在我的测试应用程序中,AndroidManifest.xml中的AppTheme2工作正常。您是否尝试重新安装该应用程序?如果您试图更改应用程序主题程序MaticallyRuntime,请在super.onCreatesavedInstanceState之前调用setThemeR.style.AppTheme2。