SRI*_*SRI 5 android splash-screen xamarin
对于新的 android 12 初始屏幕迁移,需要以下内容。
<style name="Theme.App.Starting" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/bootsplash_background</item>
<item name="windowSplashScreenAnimatedIcon">@mipmap/bootsplash_logo</item>
<item name="android:windowSplashScreenBrandingImage">@drawable/brand_logo</item>
<item name="postSplashScreenTheme">@style/AppTheme</item>
</style>
Run Code Online (Sandbox Code Playgroud)
问题是 windowSplashScreenBackground 和 windowSplashScreenBrandingImage 不被 Android <= 11 使用。那么我们如何让背景成为特定的颜色并在底部显示品牌呢?
官方文档提醒开发者在Android <= 11中使用Androidx SplashScreen compat库来做闪屏。
但它也有一些局限性:
SplashScreen兼容库链接:https://developer.android.google.cn/reference/kotlin/androidx/core/splashscreen/SplashScreen
windowSplashScreenBackground您可以在 Android <= 11 中通过以下代码与 Androidx SplashScreen 兼容库进行设置。
<item name="windowSplashScreenBackground">@android:color/white</item>
Run Code Online (Sandbox Code Playgroud)
另外,官方文档还说:可选地,您可以使用windowSplashScreenBrandingImage来设置要在启动屏幕底部显示的图像。设计指南建议不要使用品牌形象。
如果您需要更多信息,请查看官方文档:https://developer.android.google.cn/guide/topics/ui/splash-screen/migrate和 https://developer.android.com/guide/topics/ ui/启动画面
<application>此外,您需要在和中设置主题<Mainacticvity>。例如:
<application android:theme="@style/AppTheme"></application>
[Activity(Label = "@string/app_name", Theme = "@style/Theme.App.Starting", MainLauncher = true)]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3888 次 |
| 最近记录: |