移动开发

activitygroup 切换动画效果如何实现

2020-11-06 17:57:18 阅读数 4905 收藏 0
**一下提供伪代码,仅说明自己的理解,思路**/
/*************************************************/
/*假设*/
AActivity,BActivity,CActivity,DActivity 都extends ActivityGroup.
A1Activity,B1Activity,C1Activity,D1Activity 都extends Activity.
A2Activity,B2Activity,C2Activity,D2Activity 都extends Activity

/*一,AActivity继承了Activity,调用startActivity()的时候会在tab内部contentView显示A1Activity*/
AActivity.this.startActivity(A1Activity.class)
BActivity.this.startActivity(B1Activity.class)
CActivity.this.startActivity(C1Activity.class)
DActivity.this.startActivity(D1Activity.class)

/*二,A1Activity没有继承ActivityGroup,所以调用startActivity()的时候和普通的调用没有区别,A2会填满窗口*/
A1Activity.this.startActivity(A2Activity.class)
B1Activity.this.startActivity(B2Activity.class)
C1Activity.this.startActivity(C2Activity.class)
D1Activity.this.startActivity(D2Activity.class)

/*三,A1Activity.this.getParent()获得的是AActivity, 其实就是ActivityGroup; 虽然A1Activity没有继承ActivityGroup,但是A2Activity实际是由A1Activity的父类AActivity启动的,所以A2Activity的启动效果和一差不多*/
A1Activity.this.getParent().startActivity(A2Activity.class)
B1Activity.this.getParent().startActivity(B2Activity.class)
C1Activity.this.getParent().startActivity(C2Activity.class)
D1Activity.this.getParent().startActivity(D2Activity.class)