gpt4 book ai didi

android - view android的生命周期

转载 作者:太空狗 更新时间:2023-10-29 12:41:03 24 4
gpt4 key购买 nike

我希望在恢复我的 Activity 后出现一些 View 动画,但我无法在所有 View 加载之后成功捕捉到时间,并且动画在所有 View 加载之前(动画转换之前)开始。我尝试使用 onDraw、onWindowFocusChange、onResume,我发现 onDraw 是 View 生命周期的最后一个方法,但我仍然看到动画在用户看到所有 View 之前开始

最佳答案

这是在我的设备(Sony Z1 Compact)上测试的 Android Activity 生命周期和 Android View 生命周期

Start an Activity
Activity: onCreate
Activity: onStart
Activity: onResume
View: onAttachedToWindow
View: onWindowFocusChanged true
# Running
Activity: onPause
View: onWindowFocusChanged false
# Start to another Activity
# Back from another Activity
Activity: onResume
View: onWindowFocusChanged true
# Running
View: onWindowFocusChanged false
Activity: onPause
Activity: onStop
Activity: onDestroy
View: onDetachedFromWindow

Turn Off Screen
Activity: onCreate
Activity: onStart
Activity: onResume
View: onAttachedToWindow
View: onWindowFocusChanged true
# Running
Activity: onPause
Activity: onStop
View: onWindowFocusChanged false
# Turn Off Screen
# Turn On Screen
Activity: onStart
Activity: onResume
View: onWindowFocusChanged true
# Running
View: onWindowFocusChanged false
Activity: onPause
Activity: onStop
Activity: onDestroy
View: onDetachedFromWindow

Switch Application
Activity: onCreate
Activity: onStart
Activity: onResume
View: onAttachedToWindow
View: onWindowFocusChanged true
# Running
Activity: onPause
View: onWindowFocusChanged false
Activity: onStop
# Switch to Application
# Back from Application
Activity: onStart
Activity: onResume
View: onWindowFocusChanged true
# Running
Activity: onPause
View: onWindowFocusChanged false
Activity: onStop
Activity: onDestroy
View: onDetachedFromWindow

关于android - view android的生命周期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25709919/

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