博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
关于 overridePendingTransition()使用
阅读量:4350 次
发布时间:2019-06-07

本文共 1662 字,大约阅读时间需要 5 分钟。

(2013-02-19 10:52:15)
标签:

 

实现两个 Activity 切换时的动画。在Activity中使用

有两个参数:进入动画和出去的动画。

注意

1、必须在 StartActivity()  或 finish() 之后立即调用。
2、而且在 2.1 以上版本有效
3、手机设置-显示-动画,要开启状态

//实现淡入浅出的效果

startActivity(newIntent(MainActivity.this,SecondActivity.class));
overridePendingTransition(android.R.anim.fade_in,android.R.anim.fade_out);

// 由左向右滑入的效果

startActivity(newIntent(MainActivity.this,SecondActivity.class));
overridePendingTransition(android.R.anim.slide_in_left,android.R.anim.slide_out_right);

// 实现zoommin 和 zoomout (自定义的动画)

startActivity(newIntent(OverridePendingTransitionActivity.this,SecondActivity.class));
overridePendingTransition(R.anim.zoomin, R.anim.zoomout);

anim/zoomin.xml
<?xml version="1.0"encoding="utf-8"?>
<set xmlns:android=""
   android:interpolator="@android:anim/decelerate_interpolator">
  <scale
       android:duration="@android:integer/config_mediumAnimTime"
       android:fromXScale="0.1"
       android:fromYScale="0.1"
       android:pivotX="50%p"
       android:pivotY="50%p"
       android:toXScale="1.0"
       android:toYScale="1.0" />
  <alpha
       android:duration="@android:integer/config_mediumAnimTime"
       android:fromAlpha="0"
       android:toAlpha="1.0" />
</set>

anim/zoomout.xml

<?xml version="1.0"encoding="utf-8"?>
<set xmlns:android=""
   android:interpolator="@android:anim/decelerate_interpolator"
   android:zAdjustment="top" >
   <scale
       android:duration="@android:integer/config_mediumAnimTime"
       android:fromXScale="1.0"
       android:fromYScale="1.0"
       android:pivotX="50%p"
       android:pivotY="50%p"
       android:toXScale="0.1"
       android:toYScale="0.1" />
   <alpha
       android:duration="@android:integer/config_mediumAnimTime"
       android:fromAlpha="1.0"
       android:toAlpha="0" />
</set>

转载于:https://www.cnblogs.com/melons/p/5791949.html

你可能感兴趣的文章
Linux - 配置SSH免密通信 - “ssh-keygen”的基本用法
查看>>
Python(2.7.6) glob - 匹配指定模式的文件
查看>>
HTTP - 持久连接
查看>>
添加路由时啥时候是dev啥时候是gw
查看>>
redis 中文字符显示
查看>>
登录日志分析常用查询
查看>>
Codeforces Round #228 (Div. 1) 388B Fox and Minimal path
查看>>
【nosql实现企业网站系列之一】mongodb的安装
查看>>
短信服务供应商价格总览
查看>>
获取本机IP(考虑多块网卡、虚拟机等复杂情况)
查看>>
笔记之_java整理ORM框架
查看>>
CentOS下安装python3.x版本
查看>>
CAP定理(原则)以及BASE理论
查看>>
「玩转树莓派」搭建属于自己的云盘服务
查看>>
有道语料库爬虫
查看>>
VS2019 实用设置
查看>>
for循环语句之求和,阶乘,求偶,求n次篮球蹦起高度
查看>>
CFileDialog
查看>>
[转载]EXTJS学习
查看>>
SQL Server2012完全备份、差异备份、事务日志备份和还原操作
查看>>