【发布时间】:2017-04-21 07:08:17
【问题描述】:
我关注了this link 创建一个 SplashActivity,它在加载 MainActivity 时显示一个小图标。 Everythink 工作正常,我可以成功实现该图标。现在我正在尝试更改 SplashActivity 的图标,但问题是我设备上的应用程序中的图标未更新。除了主题之外,我在代码中更改的所有其他内容都将成功更新。
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:
<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:
<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、删除设备上的应用程序等),但只是主题在设备上无法正常工作,其他一切正常。
有没有人解决如何显示正确的主题?
编辑: 即使我从 mainfest 文件中删除了主题,主题仍然存在..
编辑 2: 我发现当前显示的图标是位于中间的标准 ic_launcher 图标。所以 window_background.xml 完全被主题忽略了,我仍然不知道为什么。我还尝试将不同的主题设置为 AppTheme.LauncherTheme 的父主题,但它并没有改变任何东西。如果我删除 AppTheme.LauncherTheme 则 SplashActivity 为空并且 ic_launcher 图标被删除。
【问题讨论】:
-
AppTheme.LauncherTheme 有一个名为 window_background.xml 的可绘制对象。这是正确的吗?
-
当然是我的错,我会更新问题!
标签: android xml android-studio android-theme