Android API 31启动屏应用图标过小问题求助
解决Android 12启动屏应用图标过小的问题
可能的原因及对应解决方法
1. 检查启动屏图标图层的配置
Android 12的启动屏要求应用图标作为前景层独立资源存在,需确保配置符合规范:
- 打开
res/drawable下的启动屏drawable文件(通常命名为ic_launcher_background.xml或自定义的splash资源文件) - 确认前景图标引用(
android:drawable="@mipmap/ic_launcher")指向的是正确的mipmap资源,而非被错误缩小的版本 - 若使用图层列表(layer-list),要保证前景图标的
android:gravity设为center,且未添加额外的android:width/android:height限制参数
2. 重新生成符合规范的mipmap资源
Android Studio的图像资源工具可能未正确生成适配不同dpi的图标,可重新配置生成:
- 右键
res目录 → New → Image Asset - 在Icon Type中选择Launcher Icons (Adaptive and Legacy)
- 导入你的1024x1024原始图标,先将Foreground Layer的Scale重置为100%,预览各dpi下的效果后再调整
- 生成后检查各mipmap目录下的图标尺寸是否符合系统规范:
- mdpi: 48x48px
- hdpi: 72x72px
- xhdpi: 96x96px
- xxhdpi: 144x144px
- xxxhdpi: 192x192px
3. 直接在启动屏配置中强制设置图标大小
如果上述方法无效,可直接在启动屏的layer-list文件中指定图标尺寸:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <!-- 背景层 --> <item android:drawable="@color/splash_background"/> <!-- 前景图标层 --> <item> <bitmap android:gravity="center" android:src="@mipmap/ic_launcher" android:width="120dp" android:height="120dp"/> </item> </layer-list>
注意:使用dp单位保证多设备适配,数值可根据实际需求调整。
4. 核对Splash Screen主题配置
Android 12的启动屏主题需正确关联到启动Activity:
- 在
res/values/styles.xml中确认主题设置:
<style name="Theme.App.SplashScreen" parent="Theme.SplashScreen"> <item name="windowSplashScreenBackground">@color/splash_background</item> <item name="windowSplashScreenAnimatedIcon">@mipmap/ic_launcher</item> <item name="postSplashScreenTheme">@style/Theme.App</item> </style>
- 确保
AndroidManifest.xml中启动Activity的主题为上述Splash Screen主题:
<activity android:name=".SplashActivity" android:theme="@style/Theme.App.SplashScreen"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity>
5. 清除缓存并重新构建项目
- 点击Android Studio顶部菜单栏的Build → Clean Project
- 再选择Build → Rebuild Project
- 卸载设备上的旧应用后,重新安装测试
内容的提问来源于stack exchange,提问作者Mor Sagmon
相关产品推荐
相关产品推荐

