Slide transition animation in a ActivityGroup on Android

[亡魂溺海] 提交于 2019-12-03 14:12:39

问题


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);
}


来源:https://stackoverflow.com/questions/6532678/slide-transition-animation-in-a-activitygroup-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!