gpt4 book ai didi

android - windowSplashScreenAnimationDuration 有什么作用?

转载 作者:行者123 更新时间:2023-12-05 05:57:04 26 4
gpt4 key购买 nike

Android 中的闪屏 API 引入了 windowSplashScreenAnimationDuration 。有没有人注意到它对启动画面持续时间或动画持续时间有任何影响?即使我将其设置为建议的最大值 1000 毫秒,有时启动画面的可见时间也比这短。如果我将它设置为 100 毫秒,飞溅的可见时间会更长。

此外,无论我的实际可绘制 (xml) 动画有多长 - windowSplashScreenAnimationDuration 似乎对其没有影响。

文档也很差。

有人可以阐明这一点吗?

谢谢!

最佳答案

windowSplashScreenAnimationDuration 对持续时间没有直接影响。您可以使用 SplashScreenView#getIconAnimationDuration 检索持续时间值,并在您自己的业务逻辑中使用该值。

来自 https://developer.android.com/guide/topics/ui/splash-screen#suspend-drawing

Use windowSplashScreenAnimationDuration to indicate the duration of the splash screen icon animation. Setting this won't have any effect on the actual time during which the splash screen is shown, but you can retrieve it when customizing the splash screen exit animation using SplashScreenView#getIconAnimationDuration. See Keep the splash screen for longer periods in the following section for further details.

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// ...

// Add a callback that's called when the splash screen is animating to
// the app content.
splashScreen.setOnExitAnimationListener { splashScreenView ->
// Create your custom animation.
val slideUp = ObjectAnimator.ofFloat(
splashScreenView,
View.TRANSLATION_Y,
0f,
-splashScreenView.height.toFloat()
)
slideUp.interpolator = AnticipateInterpolator()
slideUp.duration = 200L

// Call SplashScreenView.remove at the end of your custom animation.
slideUp.doOnEnd { splashScreenView.remove() }

// Run your animation.
slideUp.start()
}
}


// Get the duration of the animated vector drawable.
val animationDuration = splashScreenView.iconAnimationDuration
// Get the start time of the animation.
val animationStart = splashScreenView.iconAnimationStart
// Calculate the remaining duration of the animation.
val remainingDuration = if (animationDuration != null && animationStart != null) {
(animationDuration - Duration.between(animationStart, Instant.now()))
.toMillis()
.coerceAtLeast(0L)
} else {
0L
}

关于android - windowSplashScreenAnimationDuration 有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68927729/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com