飞溅主题不再改变 [英] Splash Theme is not changing anymore

查看:104
本文介绍了飞溅主题不再改变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我关注了此链接 创建一个SplashActivity,在加载MainActivity时显示一个小图标. Everythink运行良好,我可以成功实现该图标.现在,我正在尝试更改SplashActivity的图标,但是问题是我设备上的应用程序中的图标未更新.我在代码中更改的所有其他内容都将成功更新,除非您希望使用主题.

I followed this link to create a SplashActivity which displayed a small icon while loading the MainActivity. Everythink worked fine and I could implement the icon successfully. Now I'm trying to change the icon for the SplashActivity but the Problem is that the icon in the application on my device is not updated. Everything else I change in the code will be updated successful expect the theme.

window_background.xml:

window_background.xml:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:opacity="opaque">

<item android:drawable="@color/white"/>
<item>
    <bitmap
        android:src="@drawable/logo"
        android:gravity="center"/>
</item>
</layer-list>

styles.xml:

styles.xml:

<resources>

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

<style name="AppTheme.LauncherTheme">
    <item name="android:windowBackground">@drawable/window_background</item>
</style>

AndroidManifest.xml:

AndroidManifest.xml:

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme">
    <activity android:name=".SplashActivity"
        android:theme="@style/AppTheme.LauncherTheme"
        android:screenOrientation="sensorPortrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
...
</application>

我几乎尝试了所有更新代码的方法(清理项目,重建项目,使缓存无效,重新启动Android Studio,在设备上删除应用程序等),但是只是该主题在设备上无法正常工作,其他所有项目都可以正常工作.

I nearly tried everything to update the code (Clean Project, Rebuild Project, Invalidate Caches, restart Android Studio, Delete App on Device etc.) but just the theme is not working correctly on the device, everything else works.

有人能解决显示正确主题的问题吗?

Does anyone have a solution how to display the correct theme?

即使我从mainfest文件中删除了主题,主题仍然存在.

Even if I remove the theme from the mainfest file the theme is still there..

我发现当前显示的图标是中间居中的标准ic_launcher图标.因此,主题完全忽略了window_background.xml,我仍然不知道为什么.我还尝试将不同的主题设置为AppTheme.LauncherTheme的父主题,但它没有任何改变.如果删除AppTheme.LauncherTheme,则将SplashActivity清空,并删除ic_launcher图标.

EDIT 2: I figured out that the currently displayed icon is the standard ic_launcher icon which is centered in the middle. So the window_background.xml is completly ignored from the theme and I still don't know why. I also tried to set different themes as the parent for the AppTheme.LauncherTheme but it does not change anything. If I remove the AppTheme.LauncherTheme then the SplashActivity is emtpy and the ic_launcher icon is removed.

推荐答案

AppTheme.LauncherTheme应该扩展Theme.AppCompat主题之一.我建议这样的解决方案:

AppTheme.LauncherTheme should extend one of the Theme.AppCompat themes. I suggest such solution:

<style name="AppTheme.LauncherTheme" parent="AppTheme">

这篇关于飞溅主题不再改变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆