Android切换Activity时的淡入动画和缩小动画

news/2024/8/26 15:16:30 标签: android, encoding

原文地址:http://blog.csdn.net/xiaochun91103/article/details/6199120


一、淡入效果:

/anim/fade.xml内容如下:

<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
       android:interpolator="@android:anim/accelerate_interpolator"
       android:fromAlpha="0.0" android:toAlpha="1.0"
       android:duration="@android:integer/config_longAnimTime" />

/anim/hold.xml文件内容如下:

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
       android:interpolator="@android:anim/accelerate_interpolator"
       android:fromXDelta="0" android:toXDelta="0"
       android:duration="@android:integer/config_longAnimTime" />

调用在监听器中,像下面的代码:

overridePendingTransition(R.anim.fade, R.anim.hold);
当然Android本身也提供的有这个效果,调用如下格式:

overridePendingTransition(android.R.anim.fade_in,android.R.anim.fade_out);

二、缩小效果

/anim/zoom_enter.xml内容如下:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
        android:interpolator="@android:anim/decelerate_interpolator">
    <scale android:fromXScale="2.0" android:toXScale="1.0"
           android:fromYScale="2.0" android:toYScale="1.0"
           android:pivotX="50%p" android:pivotY="50%p"
           android:duration="@android:integer/config_mediumAnimTime" />
</set>

/anim/zoom_exit.xml内容如下:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
        android:interpolator="@android:anim/decelerate_interpolator"
        android:zAdjustment="top">
    <scale android:fromXScale="1.0" android:toXScale=".5"
           android:fromYScale="1.0" android:toYScale=".5"
           android:pivotX="50%p" android:pivotY="50%p"
           android:duration="@android:integer/config_mediumAnimTime" />
    <alpha android:fromAlpha="1.0" android:toAlpha="0"
            android:duration="@android:integer/config_mediumAnimTime"/>
</set>
调用格式:

overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit);  





http://www.niftyadmin.cn/n/1332003.html

相关文章

这份简历竟然值50w年薪?

面试官&#xff1a;用过哪些 Map我&#xff1a;LinkedHashMap、TreeMap面试官&#xff1a;说一说这两个 Map 的区别我&#xff1a;ConcurrentHashMap 线程安全&#xff0c;TreeMap 可以自定义排序面试官&#xff1a;ConcurrentHashMap 怎么保证线程安全我&#xff1a;……面试官…

编程大佬是否能记住代码,不用百度就能啪啪啪敲出来么?

点击上方“果汁简历”&#xff0c;选择“置顶公众号”有位新接触编程的新手在知乎上提问[1]&#xff1a;想知道那些编程大佬是不是代码都能记住&#xff0c;然后不用查百度就能啪啪啪打出来呢&#xff1f;从大一接触编程到现在一直在练习代码&#xff0c;但是很多函数和库还是没…

Java IO简介

Java 流在处理上分为字符流和字节流。 字符流处理的单元为 2 个字节的 Unicode 字符&#xff0c;分别操作字符、字符数组或字符串&#xff1b; 字节流处理单元为 1 个字节&#xff0c;操作字节和字节数组。 ( 一 )以字节为导向的流------InputStream/OutputStream 以字节为…

为啥查询那么慢?

1. MySQL查询慢是什么体验&#xff1f;大多数互联网应用场景都是读多写少&#xff0c;业务逻辑更多分布在写上。对读的要求大概就是要快。那么都有什么原因会导致我们完成一次出色的慢查询呢&#xff1f;1.1 索引在数据量不是很大时&#xff0c;大多慢查询可以用索引解决&#…

计算机方面经典书籍一

我的另一篇博客共享了一些优秀的书籍的电子版&#xff0c;参见 《计算机编程优秀书籍电子版共享&#xff08;持续更新……&#xff09;》 图灵教育官方博客&#xff1a;http://turingbooks.iteye.com/ Windows经典书籍 CSDN博客&#xff1a;http://blog.csdn.net/dadalan…

SpringBoot中的线程池,你真的会用么?

点击上方“果汁简历”&#xff0c;选择“置顶公众号”前言前两天做项目的时候&#xff0c;想提高一下插入表的性能优化&#xff0c;因为是两张表&#xff0c;先插旧的表&#xff0c;紧接着插新的表&#xff0c;一万多条数据就有点慢了后面就想到了线程池ThreadPoolExecutor&…

解决CRT(即C Run-Time)中函数的安全警告

解决CRT&#xff08;即C Run-Time&#xff09;中函数的安全警告 参考MSDN 1、Security Features in the CRT 2、Secure Template Overloads 是不是有时候碰到这样的警告&#xff1a; warning C4996: strcpy: This functionor variable may be unsafe. Consider using strc…

MySQL 是如何实现 ACID 的?

点击上方 果汁简历 &#xff0c;选择“置顶公众号”优质文章&#xff0c;第一时间送达作者&#xff1a;无名鼠辈llc687.top/posts/数据库/mysql的acid写在前面本文主要探讨MySQL InnoDB 引擎下ACID的实现原理&#xff0c;对于诸如什么是事务&#xff0c;隔离级别的含义等基础知…