在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>

2、加载动画:

Animation animation = AnimationUtils.loadAnimation(this, R.anim.scale);imageView1.startAnimation(animation);//开始动画
案例下载地址: http://download.csdn.net/detail/u013043346/9374204

更多相关文章

  1. Android客户端与java服务端AES加解密
  2. Android(安卓)Studio JNI开发
  3. Android(安卓)游戏开发中横竖屏切换问题
  4. LoganSquare——快速解析和序列化JSON对象的Android类库
  5. Android架构实例分析之注册hello HAL的JNI方法表
  6. Android(安卓)5.0+ 高级动画开发系列 矢量图动画
  7. Android(安卓)MonkeyRunner测试NotePad例子(SDK中的源码实例)
  8. android中apk反编译
  9. OpenGL.Shader:1-重新认识Android上OpenGL(纯Cpp)

随机推荐

  1. 【初用Android Studio】快捷键之代码提示
  2. Jollen 的 Android 教學,#17: 樣式設計(St
  3. Android(安卓)开发艺术探索笔记之八 --
  4. <application android:debuggable="false
  5. 单板机上Android通过Modbus RTU操控外设
  6. android的selector-背景选择器
  7. 被谷歌控制的 Android(安卓)不是好 Andro
  8. 史上最全的Java&Android面试题搜集整理
  9. Android 模块通信—— EventBus
  10. android中scaleType详解