Android--Animation动画学习

1、动画主要分为两种模式

1.1、补间动画(tweened animation

补间动画又可以分为四种形式,分别是 alpha(淡入淡出),translate(位移),scale(缩放大小),rotate(旋转)

xml的实现 

首先需要在res/anim/ 文件夹下定义如下的动画实现方式

alpha动画实现

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

scale动画实现

<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android" 
android:duration="1000" 
android:fromXScale="0.0" 
android:fromYScale="0.0" 
android:pivotX="50%" 
android:pivotY="50%" 
android:toXScale="1.0" 
android:toYScale="1.0"/>

1.2、帧动画(Frame Animation

帧动画是最容易实现的一种动画,这种动画更多的依赖于完善的UI资源,它的原理就是将一张张单独的图片连贯的进行播放,

从而让人在视觉上产生一种动画的效果。

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"> 
<item android:drawable="@drawable/image1" android:duration="100" /> 
<item android:drawable="@drawable/image2" android:duration="100" /> 
<item android:drawable="@drawable/image3" android:duration="100" />
</animation-list>


猜你喜欢

转载自blog.csdn.net/xiyunmengyuan/article/details/80938184