Java乔晓松-android中的Tween动画的使用
来源:互联网 发布:电脑便签软件 编辑:程序博客网 时间:2024/05/14 05:14
Tween动画的使用,我试过的有移动效果、旋转效果、透明效果和缩放效果以及混合动画
下面我给大家完整的代码和详细的解释:
MainActivity.java源码:
package com.example.lesson19_tween;import android.app.Activity;import android.os.Bundle;import android.view.Menu;import android.view.View;import android.view.animation.Animation;import android.view.animation.AnimationUtils;import android.widget.ImageView;/** * 2013-6-28 上午9:09:49 * * @author 乔晓松 */public class MainActivity extends Activity {private ImageView imageView;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);imageView = (ImageView) findViewById(R.id.iv_01);}@Overridepublic boolean onCreateOptionsMenu(Menu menu) {// Inflate the menu; this adds items to the action bar if it is present.getMenuInflater().inflate(R.menu.main, menu);return true;}public void translateImpl(View v) {// xml文件的Tween动画 移动的效果Animation animation = AnimationUtils.loadAnimation(this,R.anim.translate);// 循环动画,动画一直循环的移动animation.setRepeatCount(Animation.INFINITE);// imageView.setAnimation(animation);// animation.start();imageView.startAnimation(animation);// Java代码实现的Tween动画效果// TranslateAnimation translateAnimation = new TranslateAnimation(0,// 320,// 0, 0);// translateAnimation.setDuration(2000);// imageView.startAnimation(translateAnimation);}// 缩放动画public void scaleImpl(View v) {Animation animation = AnimationUtils.loadAnimation(this, R.anim.scale);imageView.startAnimation(animation);}// 旋转动画public void rotateImpl(View v) {Animation animation = AnimationUtils.loadAnimation(this, R.anim.rotate);imageView.startAnimation(animation);}// 透明动画public void alphaImpl(View v) {Animation animation = AnimationUtils.loadAnimation(this, R.anim.alpha);imageView.startAnimation(animation);}public void setImpl(View v) {Animation animation = AnimationUtils.loadAnimation(this, R.anim.set);imageView.startAnimation(animation);}}
移动效果的代码如下:2000表示2000毫秒移动一次
<translate xmlns:android="http://schemas.android.com/apk/res/android" android:duration="2000" android:fromXDelta="0" android:fromYDelta="0" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:toXDelta="320" android:toYDelta="0" />
缩放效果的代码如下:50%都表示缩放的比例
<scale xmlns:android="http://schemas.android.com/apk/res/android" android:fromXScale="0.2" android:fromYScale="0.2" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:pivotX="50%" android:pivotY="50%" android:toXScale="1.0" android:toYScale="1.0" android:duration="2000" />
旋转效果的代码如下:0代表开始旋转的°数,360代表360°
<rotate xmlns:android="http://schemas.android.com/apk/res/android" android:duration="2000" android:fromDegrees="0" android:pivotY="1" android:repeatCount="infinite" android:repeatMode="reverse" android:toDegrees="360" />透明效果的代码如下:代码中的1代表开始不透明,0.1是最后的透明效果是0.1接近完全透明
<alpha xmlns:android="http://schemas.android.com/apk/res/android" android:duration="2000" android:fromAlpha="1" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:toAlpha="0.1" />所谓的混合效果,就是上面的几种效果叠加的效果,用set集合就可以实现,代码如下:
<set xmlns:android="http://schemas.android.com/apk/res/android" android:shareInterpolator="false" > <scale android:duration="700" android:fillAfter="false" android:fromXScale="1.0" android:fromYScale="1.0" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:pivotX="50%" android:pivotY="50%" android:toXScale="1.4" android:toYScale="0.6" /> <alpha android:duration="2000" android:fromAlpha="1" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:toAlpha="0.1" /> <set android:interpolator="@android:anim/decelerate_interpolator" > <scale android:duration="400" android:fillBefore="false" android:fromXScale="1.4" android:fromYScale="0.6" android:pivotX="50%" android:pivotY="50%" android:startOffset="700" android:toXScale="0.0" android:toYScale="0.0" /> <rotate android:duration="400" android:fromDegrees="0" android:pivotX="50%" android:pivotY="50%" android:startOffset="700" android:toDegrees="-45" android:toYScale="0.0" /> </set></set>
- Java乔晓松-android中的Tween动画的使用
- Android Animation Tween动画效果的使用
- Android Animation Tween动画效果的使用
- android 动画-Tween Animation(二) 动画的简单使用
- Android中的动画效果学习之二---Tween动画(使用XML文件进行配置动画效果)
- android Tween Animations(动画效果-代码实现)的使用
- Android补间动画(Tween Animation)的使用总结
- android的动画之Tween动画
- Android中的tween动画, 帧动画, 和3.0以后的属性动画的用法及不同!
- Android:动画:tween动画
- android 动画 -- tween动画
- android中的tween动画(也叫view动画)原理以及使用详解
- Android开发之使用Tween动画
- Android的Tween动画的实现框架
- Android的Tween动画的实现框架
- Android的Tween动画的实现框架
- Android的Tween Animation动画介绍
- Android Tween动画的四种方式
- VBScript数组函数
- 黑马程序员---关于JAVA中JDK1.5新特性
- Ural-1068. Sum(水题)
- Emacs配置记录
- 百度SEO与谷歌SEO的10大区别
- Java乔晓松-android中的Tween动画的使用
- arcgis入门到精通视频教程下载连接
- DFS 对一系列给定数据 进行深度优先遍历 获得54321的所有可能组合
- win7 OrCAD Capture 找不到MSVCR90.dll
- Linux网络安装介绍1
- Win7 线程语言设置错误可能引起窗口排版变化
- 0630学习笔记
- TCP流式套接字的基本编程
- 使用POI读取excel文件内容