Slide transition animation in a ActivityGroup on A

2019-03-17 01:38发布

问题:

I want to add slide transition animation while changing activities within a ActivityGroup. I have used following function to change activities using intent:

public void replaceContentView(String id, Intent newIntent) {
    View view = getLocalActivityManager().startActivity(id,
            newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
            .getDecorView();
    history.add(view);
    this.setContentView(view);
}

Any suggestion how can I do that?

回答1:

add animation to the view

Example

public void replaceContentView(String id, Intent newIntent) {
    View view = getLocalActivityManager().startActivity(id,
            newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
            .getDecorView();

Animation hyperspaceJump = 
     AnimationUtils.loadAnimation(this, R.anim.myanimation);
    view.startAnimation(hyperspaceJump);
 history.add(view);
    this.setContentView(view);
}