六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 41|回复: 0

Animation之Rotate

[复制链接]

升级  5%

61

主题

61

主题

61

主题

举人

Rank: 3Rank: 3

积分
215
 楼主| 发表于 2013-1-15 02:50:55 | 显示全部楼层 |阅读模式
Animation是Android中用来处理各种动画效果的类,如果你想了解他具体的可以处理哪些动画以及是如何处理的,请猛击这里。这里讲解了Animation的机制,其实,Animation分为两种:一种是Tween,就是处理平移,旋转,缩放,改变透明度等;另外一种是Frame动画,相当于电影胶片的效果。下面是实现的Rotate效果,好了。
     首先,在res下新建一anim文件夹(当然不是必须的),然后新建一xml文档,xml代码如下:
<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android"><rotate   android:interpolator="@android:anim/accelerate_decelerate_interpolator"     android:fromDegrees="0"      android:toDegrees="+360"     android:duration="10000" /></set> 然后,在java文件中写入如下代码:
import android.app.Activity;  import android.os.Bundle;   import android.view.animation.Animation;  import android.view.animation.AnimationUtils;     public class RotateAnimation extends Activity{  public void onCreate(Bundle savedInstanceState) {          super.onCreate(savedInstanceState);           setContentView(R.layout.main);           Animation anim = AnimationUtils.loadAnimation(this, R.anim.my_rotate);           findViewById(R.id.TextView01).startAnimation(anim);      }   }  运行,运行开始时,textView中的文字会旋转360度。如图:
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表