Android 未应用自定义应用程序主题
我在styles.xml文件中创建了这个名为carcover的自定义应用程序主题 当我在emulator中运行应用程序时,主题似乎是AppTheme,而不是木炭Android 未应用自定义应用程序主题,android,Android,我在styles.xml文件中创建了这个名为carcover的自定义应用程序主题 当我在emulator中运行应用程序时,主题似乎是AppTheme,而不是木炭 为什么会这样?因为您在活动中覆盖了它。android:theme=@style/AppTheme.NoActionBar>如果你想让它成为木炭和NoActionBar,你需要制作一个既能做木炭又能做木炭的主题。,因为你已经将android:theme=@style/AppTheme.NoActionBar放置在你的清单活动中,覆盖了应用
为什么会这样?因为您在活动中覆盖了它。android:theme=@style/AppTheme.NoActionBar>如果你想让它成为木炭和NoActionBar,你需要制作一个既能做木炭又能做木炭的主题。,因为你已经将android:theme=@style/AppTheme.NoActionBar放置在你的清单活动中,覆盖了应用程序的主题。所以把那条线去掉
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- 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="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<!-- custom -->
<style name="Charcoal" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:windowBackground">@color/charcoalBackground</item>
<item name="colorPrimary">@color/charcoalPrimary</item>
<item name="colorPrimaryDark">@color/charcoalPrimaryDark</item>
<item name="colorAccent">@color/gold</item>
</style>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="gold">#FFD700</color>
<color name="charcoalBackground">#272727</color>
<color name="charcoalPrimary">#595858</color>
<color name="charcoalPrimaryDark">#3a3a3a</color>
</resources>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Charcoal">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>