如何在不改变当前主题的情况下实现Android闪屏API

问题描述 投票:0回答:1

我想将 Android Splash Screen API 添加到基于 this document 的已经开发的项目中,该项目有自己的样式和主题。在文档中,它说我的清单的

theme
标签中的
application
应该设置为必须继承自
"Theme.SplashScreen"
的新主题,并且它内部也有一些必需的标签,如下所示:

<style name="Theme.AppSplash" parent="Theme.SplashScreen">
    <item name="windowSplashScreenBackground">@color/green</item>
    <item name="windowSplashScreenAnimatedIcon">@drawable/sample_splash</item>
    <item name="windowSplashScreenAnimationDuration">1000</item>
   
</style

虽然我的项目旧主题继承自其他主题,但我无法更改它,而且我也无法对主题使用双重继承(

style
标签)。 所以我的问题是,对于这样一个已经使用了一些主题并且还希望从 Android 新的
Splash Screen API
中受益的项目可以做什么?

android splash-screen android-theme android-splashscreen
1个回答
0
投票

是的,您可以使用以下步骤实现新的闪屏 API,而不会干扰旧的应用程序主题

• 添加默认应用程序主题至

<application> android:theme="old theme" ...</application>

• 创建可扩展的启动器屏幕

Activity

• 将

Theme.AppSplash
(有问题声明)分配给
android:theme
文件中
Activity
标记的
manifest

• 导航到您要显示的下一个屏幕

© www.soinside.com 2019 - 2024. All rights reserved.