
我想为不同的活动定义两个窗口动画样式.
这是我到目前为止:
表现:
Styles.xml:
我想要实现的是:
样式A的活动之间的转换应使用CustomActivityAnimation中定义的动画.
样式B的活动被设置为对话框,并且应该具有CustomDialogAnimation中定义的其他过渡动画.
我的问题:
从样式B关闭活动时,从不使用样式CustomDialogAnimation中的android:windowExitAnimation.而是播放样式CustomActivityAnimation中的android:activityCloseExitAnimation.
任何提示?
最佳答案为了您的目的,您可以在运行时给它,如下所示:我们总共需要四个动画,我们将通过XML定义它们.在四个动画中,实际上有两组.第一种是将视图从当前位置移动到视野外的位置,第二种是从视图中移出视图.
定义动画XML文件:
slide_to_left.xml:
slide_to_right.xml:
slide_from_left.xml:
slide_from_right.xml:
Just as easy is animating the transition between Activities. The
Activity class provides us with a method called
overridePendingTransition that we can use to set the animation of the
exiting and entering Activities,like so:
Intent intent = new Intent(this,B.class);startActivity(intent);overridePendingTransition(R.anim.slide_from_right,R.anim.slide_to_left);使用我们之前定义的动画,我们可以从视图的右侧滑入新的Activity,并将当前的Activity滑出视图左侧.
Similarly,when the new Activity is finished,we can perform the
reverse animation to have the finished Activity slide out of view to
the right,and the previous Activity slide back into view from the
left:
finish();overridePendingTransition(R.anim.slide_from_left,R.anim.slide_to_right);Handling on back button:
@Overridepublic void onBackPressed() { super.onBackPressed(); overridePendingTransition(R.anim.slide_from_left,R.anim.slide_to_right);}credit 总结
以上是内存溢出为你收集整理的android – 不同的退出/输入动画全部内容,希望文章能够帮你解决android – 不同的退出/输入动画所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)