标签:color rac ref 对象 java ace .com image div
在android开发。我们会常常使用到缩放动画,普通情况下缩放动画有两种实现方式。一种是直接通过java代码去实现,第二种是通过配置文件实现动画,以下是两种动画的基本是用法:
Java代码实现:
//创建缩放动画对象 Animation animation = new ScaleAnimation(0, 1.0f, 0f, 1.0f); animation.setDuration(1500);//动画时间 animation.setRepeatCount(3);//动画的反复次数 animation.setFillAfter(true);//设置为true,动画转化结束后被应用 imageView1.startAnimation(animation);//開始动画
1、首先要在res文件夹下建立一个anim文件,在anim建立一个scale.xml文件例如以下:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:duration="1500"
android:fillAfter="true"
android:fromXScale="0.0"
android:fromYScale="0.0"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:pivotX="0%"
android:pivotY="50%"
android:toXScale="1.0"
android:toYScale="1.0"
/>
</set>
Animation animation = AnimationUtils.loadAnimation(this, R.anim.scale); imageView1.startAnimation(animation);//開始动画案例下载地址:http://download.csdn.net/detail/u013043346/9374204
标签:color rac ref 对象 java ace .com image div
原文地址:http://www.cnblogs.com/jzssuanfa/p/7040097.html