手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >Android动画之ScaleAnimation
Android动画之ScaleAnimation
摘要:1.缩放动画ScaleAnimationscale_animation.xmlandroid:fromXScale=”1”——x轴从本身大小...

1.缩放动画ScaleAnimation

scale_animation.xml

<?xml version="1.0" encoding="utf-8"?>
<set
 xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="2000"
android:fillAfter="true" android:interpolator="@android:anim/accelerate_decelerate_interpolator">

    <scale
 android:fromXScale="1"
 android:toXScale="2"
 android:fromYScale="1"
 android:toYScale="2"
 android:pivotX="50%"
 android:pivotY="50%"
 android:repeatCount="0"/>

</set>

android:fromXScale=”1”——x轴从本身大小开始缩放

android:toXScale=”2”——x轴缩放到自己的一倍

android:fromYScale=”1”——y轴从本身大小开始缩放

android:toYScale=”2”——y轴缩放到自己的一倍

android:pivotX=”50%”——x轴从中心点缩放

android:pivotY=”50%”——y轴从中心点缩放

android:repeatCount=”0”——不重复

2.代码中使用动画

//利用资源文件加载动画

//mAnimation = AnimationUtils.loadAnimation(MainActivity.this,R.anim.rotate_animation);

//mImg.startAnimation(mAnimation);

//在代码中使用动画

RotateAnimation animation = new RotateAnimation(0, 360,

RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);

//不停顿

animation.setInterpolator(new LinearInterpolator());

//重复次数

animation.setRepeatCount(0);

animation.setFillAfter(true);

animation.setDuration(2000);

//开启动画

mImg.startAnimation(animation);

3.运行截图

Android动画之ScaleAnimation1

4.源码下载

下载地址:https://github.com/zeke123/Animation

【Android动画之ScaleAnimation】相关文章:

Android 动画之AlphaAnimation应用详解

Android 模拟器和PC物理键盘映射

Android 动画之RotateAnimation应用详解

android程序启动画面-Splash

Android开发之线性布局

Android开发笔记之:Splash的实现详解

Android开发之OpenGL ES 基础

android内存优化之图片优化

Android 自定义View的使用介绍

Android图片翻转动画简易实现代码

精品推荐
分类导航