在早于 Android 12 的 Android 版本上,我可以轻松构建带有未裁剪图像的启动屏幕。例如 Android 11 上是这样的:
然而,Android 12 引入了新的启动屏幕 API,我不知道如何在 Android 12 中重现上面的启动屏幕。它似乎总是被裁剪,在 Android 12 上结果如下:
这是我android/src/main/res/values/styles.xml
的旧 Android 版本(例如 Android 11):
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">@drawable/launch_background</item>
<item name="android:windowFullscreen">false</item>
</style>
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
这是我android/src/main/res/values-v31/styles.xml
的 Android 12:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowSplashScreenAnimatedIcon">@drawable/launch_background</item>
<item name="android:windowFullscreen">false</item>
</style>
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
两者之间的唯一区别styles.xml
是我用于android:windowSplashScreenAnimatedIcon
Android 12 和android:windowBackground
旧版 Android 版本,如新启动屏幕 …
android-12 ×1