简体   繁体   中英

resuming animation after onPause () android - java

just simple question I have an animation where I should put them ? in On-create or in On-resume or where ? so that when I pause the activity the animation is paused .. not played in background ! and when I resume the Activity the animation resumes .. not start from zero ! ?

my animation is like that :

view.startAnimation(AnimationUtils.loadAnimation(this, R.anim.slide);

You should stop your animation in onPause() and start your animation again in onResume()

Check out this Activity Lifecycle diagram to guide you :)

在此处输入图片说明

onPause is invoked when a popup appears and the Activity is partly visible. After the popup is removed, then onResume is invoked. When Activity is hidden and shown again later, those methods are again invoked, so they are your best choise.

About starting and stopping animations - this article should help you

About pausing animation - this article should help you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM