安卓12+动画启动屏幕API不工作



我正试图将新的Android动画启动屏幕添加到我的应用程序中,但它没有显示。

theme.xml:

...
<style name="Theme.MySplash" parent="Theme.SplashScreen">
<item name="windowSplashScreenAnimatedIcon">@drawable/news_avd_v02</item>
<item name="postSplashScreenTheme">@style/Theme.xxx.NoActionBar</item>
<item name="windowSplashScreenIconBackgroundColor">@color/pink_300</item>
<item name="windowSplashScreenAnimationDuration">3000</item>
<!-- Status bar and Nav bar configs -->
<item name="android:statusBarColor">@color/black</item>
<item name="android:navigationBarColor">@color/black</item>
<item name="android:windowLightStatusBar">false</item>
</style>
...

AndroidManifest.xml:

<application
...
android:theme="@style/Theme.MySplash">

<activity
android:name=".MainDrawerActivity"
...
android:theme="@style/Theme.MySplash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
...

主抽屉活动.kt:

...
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
...
class MainDrawerActivity : AppCompatActivity() {
...
override fun onCreate(savedInstanceState: Bundle?) {
val splashScreen = installSplashScreen()
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
...

我已经尝试过杀死这个应用程序并重新启动它,但它仍然没有显示动画。

替换windowSplashScreenAnimatedCon->安卓:windowSplashScreenAnimatedCon

最新更新