Animation之Rotate
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度。如图:
http://dl.iteye.com/upload/picture/pic/46545/369e2d83-c721-3bb0-bb38-dae05e1d740b.jpg
页:
[1]