overridePendingTransition的简介

/**
 * 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的用法,差不多就是这样了。。。。有啥问题还请多多指导。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值