1. 渐入动画

 // Request the next activity transition (here starting a new one).
startActivity(new Intent(Animation.this, AlertDialogSamples.class));
// Supply a custom animation. This one will just fade the new
// activity on top. Note that we need to also supply an animation
// (here just doing nothing for the same amount of time) for the
// old activity to prevent it from going away too soon.
overridePendingTransition(R.anim.fade, R.anim.hold);

  

R.anim.fade和 R.anim.hold.如下:

<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2007 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--> <alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_longAnimTime"
android:fromAlpha="0.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:toAlpha="1.0" />

  

<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2009 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--> <translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_longAnimTime"
android:fromXDelta="0"
android:interpolator="@android:anim/accelerate_interpolator"
android:toXDelta="0" />

  

2.快速进入动画

 // Request the next activity transition (here starting a new one).
startActivity(new Intent(Animation.this, AlertDialogSamples.class));
// This is a more complicated animation, involving transformations
// on both this (exit) and the new (enter) activity. Note how for
// the duration of the animation we force the exiting activity
// to be Z-ordered on top (even though it really isn't) to achieve
// the effect we want.
overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit);

  

R.anim.zoom_enter 和 R.anim.zoom_exit 如下:

<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 2009, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
--> <!-- Special window zoom animation: this is the element that enters the screen,
it starts at 200% and scales down. Goes with zoom_exit.xml. -->
<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>

  

<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 2009, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
--> <!-- Special window zoom animation: this is the element that exits the
screen, it is forced above the entering element and starts at its
normal size (filling the screen) and scales down while fading out.
This goes with zoom_enter.xml. -->
<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>

  

3. 中心渐变进入

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {

要有版本限制,低版本是不支持的。

            // Create a more complicated animation, involving transformations
// on both this (exit) and the new (enter) activity. Note how for
// the duration of the animation we force the exiting activity
// to be Z-ordered on top (even though it really isn't) to achieve
// the effect we want.
ActivityOptions opts = ActivityOptions.makeCustomAnimation(Animation.this,
R.anim.zoom_enter, R.anim.zoom_enter);
// Request the activity be started, using the custom animation options.
startActivity(new Intent(Animation.this, AlertDialogSamples.class), opts.toBundle()); 中心快速同理如上。

  

中心缩放的2种形式:

 // Create a scale-up animation that originates at the button
// being pressed.
ActivityOptions opts = ActivityOptions.makeScaleUpAnimation(
v, 0, 0, v.getWidth(), v.getHeight());
// Request the activity be started, using the custom animation options.
startActivity(new Intent(Animation.this, AlertDialogSamples.class), opts.toBundle());
有版本限制,如上。

  

// Create a thumbnail animation.  We are going to build our thumbnail
// just from the view that was pressed. We make sure the view is
// not selected, because by the time the animation starts we will
// have finished with the selection of the tap.
v.setDrawingCacheEnabled(true);
v.setPressed(false);
v.refreshDrawableState();
Bitmap bm = v.getDrawingCache();
Canvas c = new Canvas(bm);
//c.drawARGB(255, 255, 0, 0);
ActivityOptions opts = ActivityOptions.makeThumbnailScaleUpAnimation(
v, bm, 0, 0);
// Request the activity be started, using the custom animation options.
startActivity(new Intent(Animation.this, AlertDialogSamples.class), opts.toBundle());
v.setDrawingCacheEnabled(false); 有版本限制,如上所示。

  

Android 常用动画小结的更多相关文章

  1. Android常用动画Frame-By-Frame Animations的使用

    在Android的动画中有一种叫做Frame by Frame 的动画效果,就是跟Flash播放一样,是一帧一帧地显示,如果动画是连续并且有规律的话,就跟播放视频一样. 首先在drawable目录下添 ...

  2. Android常用动画alpha和rotate同时使用

    Android的动画可以是一种动画,也可以多种动画作用于一张图片上,如RotaeAnimation和AlphaAnimation同时放到一个配置文件中 alpha1.xml <?xml vers ...

  3. Android 常用动画

    一.动画类型 Android的animation由四种类型组成:alpha.scale.translate.rotate XML配置文件中 alpha :渐变透明度动画效果 scale :渐变尺寸伸缩 ...

  4. Android常用动画Animation的使用

    Andriod中有几种常用的Animation AlphaAnimation  淡入淡出效果 RotateAnimation 旋转效果 ScaleAnimation 缩放动画 TranslaAnima ...

  5. Android 常用动画之RotateAnimation

    前两天接到任务做一个UI,有用到动画,于是抽空看了下Android动画相关知识. Android Animation共有四大类型,分别是 Alpha      透明度动画 Scale      大小伸 ...

  6. Android属性动画之ValueAnimation

    ValueAnimation是ObjectAnimation类的父类,经过前几天的介绍,相信大家对ObjectAnimation有了 一定的认识,今天就为大家最后介绍一下ValueAnimation, ...

  7. 79.Android之动画基础

    转载:http://a.codekk.com/detail/Android/lightSky/%E5%85%AC%E5%85%B1%E6%8A%80%E6%9C%AF%E7%82%B9%E4%B9%8 ...

  8. Android属性动画完全解析(上),初识属性动画的基本用法

    转载请注明出处:http://blog.csdn.net/guolin_blog/article/details/43536355 在手机上去实现一些动画效果算是件比较炫酷的事情,因此Android系 ...

  9. Android属性动画完全解析(中)

    转载:http://blog.csdn.net/guolin_blog/article/details/43536355 大家好,在上一篇文章当中,我们学习了Android属性动画的基本用法,当然也是 ...

随机推荐

  1. bootstrap-js(2)下拉菜单

    1.下面的实例演示了在导航栏内和标签内的下拉菜单的用法: <!DOCTYPE HTML><html><head><link href="/style ...

  2. js中跳转

    <li><a href="javascript:recordRescSifting('+subject.subId+');">'+subject.subNa ...

  3. C++中重载、重写(覆盖)和隐藏的区别实例分析

    这篇文章主要介绍了C++中重载.重写(覆盖)和隐藏的区别,是C++面向对象程序设计非常重要的概念,需要的朋友可以参考下 本文实例讲述了C++中重载.重写(覆盖)和隐藏的区别,对于C++面向对象程序设计 ...

  4. Java提高学习之Object(2)

    Equality 问:euqals()函数是用来做什么的? 答:equals()函数可以用来检查一个对象与调用这个equals()的这个对象是否相等. 问:为什么不用“==”运算符来判断两个对象是否相 ...

  5. jquery解决onmouseover和onmouseout合用的bug问题

    经常会遇到鼠标放到一个元素上显示另外一个元素,这两个元素是父子关系,比如在A上绑定mouseover和mouseout事件来显示或隐藏B元素,A元素包含B元素,当鼠标移到B元素后浏览器认为你移开了A, ...

  6. Linux网络管理——IP地址

    1. 网络基础 .note-content {font-family: "Helvetica Neue",Arial,"Hiragino Sans GB",&q ...

  7. javascript每日一练—运动

    1.弹性运动 运动原理:加速运动+减速运动+摩擦运动: <!doctype html> <html> <head> <meta charset="u ...

  8. IP校验和

    #include <stdio.h> #include <unistd.h> #include <linux/if_ether.h> #include <li ...

  9. [转]iOS UIAppearance使用详解

    在iOS 5以前,自定义原生控件的外观并没有原生支持,因此开发人员感觉很麻烦.开发人员经常面临的问题是修改一个控件所有实例的外观.解决这个问题的正确方法是重写一遍控件.但由于这么做非常费时,一些开发人 ...

  10. Qt:基于TCP和UDP的局域网P2P(局域网)通讯封装

    封装了一个类,可以进行在局域网进行P2P通讯(仅局域网可用) 也就是说,假设局域网中有10台电脑,那么从本机发出的数据,将依次派发到这10台电脑(目前的设计中包括自己这台) 在使用方面,构造的时候给端 ...