/** * 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) { } } 从源码来看指的是从一个Activity跳转到另一个Activity的一个动画,enterAnim 是进入动画,exitAnim 是退出动画。在Android2.0以上overridePendingTransition就可以实现这个动画。特别注意的是: 1、必须是在startActivity之后或者是finsh之后。 2、只适用于Android2.0以上版本。 有时候overridePendingTransition这个方法却不起作用,原因在于以下几点: 1、Android2.0以下版本。 2、嵌入ActivityGroup等时。我们应该用this.getParent().overridePendingTransition来解决。 3、在内部内或者匿名类中可以用handler来解决。 以上就是overridePendingTransition的用法,差不多就是这样了。。。。有啥问题还请多多指导。
overridePendingTransition的简介
最新推荐文章于 2016-12-06 16:02:46 发布