Android12的SplashScreen适配

封面

废话不多说,直接上代码

添加到themes.xml中,然后把需要展示的activity的theme设置为这个就行。当然也可以直接在application字段下全局设置,这样冷启动的时候就会展示splashscreen

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<style name="MySplashScreen" parent="@style/Theme.崩坏丶12306">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<!-- 启动画面背景颜色 -->
<item name="android:windowSplashScreenBackground">@color/material_dynamic_neutral20</item>
<!-- 启动画面中间显示的图标,默认使用应用图标 -->
<item name="android:windowSplashScreenAnimatedIcon">@mipmap/appicon</item>
<!-- 启动画面中间显示的图标的背景,如果图标背景不透明则无效 -->
<item name="android:windowSplashScreenIconBackgroundColor">@color/material_dynamic_neutral50</item>
<!-- 启动画面启动画面底部的图片。 -->
<item name="android:windowSplashScreenBrandingImage">@mipmap/splash12306</item>
<!-- 启动画面在关闭之前显示的时长。最长时间为 1000 毫秒。 -->
<item name="android:windowSplashScreenAnimationDuration">1000</item>
</style>

好耶又水了一篇文


Android12的SplashScreen适配
http://blog.coolenoch.ink/2023/08/23/4Android12的SplashScreen适配-230823/
作者
CoolestEnoch
发布于
2023年8月23日
许可协议