Android Activity实现切换动画的两种方法
16lz
2021-01-23
方法一 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的使用
更多相关文章
- android 自定义组件随着手指自动画圆
- android中opengl es基本方法使用说明
- android 沉浸式状态栏的三种方法
- Android平移动画
- 16 个Android 开发者必备工具资源
- android资源合集
- JS判断终端类型的几种方法