黑马程序员技术交流社区
标题:
android动画效果
[打印本页]
作者:
y1787257661
时间:
2015-1-9 00:57
标题:
android动画效果
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.TranslateAnimation;
import android.widget.Button;
public class TranslateText001Activity extends Activity implements AnimationListener {
private Button btn;
private TranslateAnimation ta1,ta2,ta3;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btn=(Button) findViewById(R.id.btn1);
ta1=new TranslateAnimation(0, 200, 0, 0);
ta1.setDuration(1000);
ta1.setAnimationListener(this);
btn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
btn.startAnimation(ta1);
}
});
}
public void onAnimationEnd(Animation animation) {
ta2=new TranslateAnimation(200, 200, 0, 200);
ta2.setDuration(1000);
btn.startAnimation(ta2);
ta3=new TranslateAnimation(200,0, 200 ,0);
ta3.setDuration(1000);
btn.startAnimation(ta3);
}
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
}
复制代码
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2