Android(安卓)Activity实现切换动画的两种方法
16lz
2021-12-04
方法一 overridePendingTransition(0,0)
void android.app.Activity.overridePendingTransition(int enterAnim, int exitAnim)Call immediately after one of the flavors of startActivity(Intent) or finish to specify an explicit transition animation to perform next.Parameters:enterAnim A resource ID of the animation resource to use for the incoming activity. Use 0 for no animation.exitAnim A resource ID of the animation resource to use for the outgoing activity. Use 0 for no animation.
在Activity中提供了overridePendingTransition函数, 用在startActivity(Intent) 和 finish之后 。overridePendingTransition有两个参数,都是int类型的,意味着这里要传入一个资源。一个是进入的动画,一个是退出的动画,如果连个值都设置成0,则表示不添加动画。 animationdrable资源举例:
<?xml version="1.0" encoding="utf-8"?>
或考虑直接使用安卓自带的动画资源android.R.anim.*
方法二 android:theme
parent="@android:style/Animation.Activity"不可少,android:theme的使用
更多相关文章
- 浅谈Java中Collections.sort对List排序的两种方法
- Python list sort方法的具体使用
- python list.sort()根据多个关键字排序的方法实现
- Android(安卓)DOC文档分析——Dialog
- android中opengl es基本方法使用说明
- android 自定义组件随着手指自动画圆
- android 沉浸式状态栏的三种方法
- Android菜单实现两种方式
- Android(安卓)系统中GPS Location Service 的实现与架构