失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > Activity进入退出时的动画设置

Activity进入退出时的动画设置

时间:2022-06-18 14:39:04

相关推荐

Activity进入退出时的动画设置

Android为在进入和退出Activity时提供了设置动画的接口:

/*** Call immediately after one of the flavors of {@link #startActivity(Intent)}* or {@link #finish} to specify an explicit transition animation to* perform next.** <p>As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN} an alternative* to using this with starting activities is to supply the desired animation* information through a {@link ActivityOptions} bundle to* {@link #startActivity(Intent, Bundle) or a related function. This allows* you to specify a custom animation even when starting an activity from* outside the context of the current top activity.** @param enterAnim A resource ID of the animation resource to use for* the incoming activity. Use 0 for no animation.* @param exitAnim A resource ID of the animation resource to use for* the outgoing activity. Use 0 for no animation.*/public void overridePendingTransition(int enterAnim, int exitAnim) {try {ActivityManagerNative.getDefault().overridePendingTransition(mToken, getPackageName(), enterAnim, exitAnim);} catch (RemoteException e) {}}

1. 在startActivity和finish之后紧接着调用

2. enterAnim: 进入Activity 的进入动画对应的资源id

exitAnim: 退出Activity 的动画效果对应的资源id

如果觉得《Activity进入退出时的动画设置》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。