android的动画
来源:互联网 发布:中小学网络答题活动 编辑:程序博客网 时间:2024/06/05 14:22
package one.bw.com.donghua;import android.animation.Animator;import android.animation.AnimatorSet;import android.animation.ObjectAnimator;import android.os.Bundle;import android.support.v7.app.AppCompatActivity;import android.view.View;import android.view.animation.AccelerateInterpolator;import android.widget.ImageView;import android.widget.Toast;public class MainActivity extends AppCompatActivity { private ImageView imageView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); imageView = (ImageView) findViewById(R.id.image_view); } //位移动画 public void trans(View view) { //参数1,,控件,,参数2,,x或y轴,,参数3,,动画的起始位置,,参数4,,动画的结束位置 ObjectAnimator animator = ObjectAnimator.ofFloat(imageView, "x", imageView.getTop(), 300); animator.setDuration(3000);//动画执行的时间 animator.setInterpolator(new AccelerateInterpolator());//加速的插值器 animator.start();//启动动画 //动画的监听事件 animator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { } @Override public void onAnimationEnd(Animator animator) { Toast.makeText(MainActivity.this,"动画结束",Toast.LENGTH_SHORT).show(); } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); } //旋转动画 public void rotrate(View view) { //参数1...控件,,参数2...x或y轴,,,参数3..起始角度,,,参数4...旋转角度 ObjectAnimator animator = ObjectAnimator.ofFloat(imageView, "rotationY", 0, 360); animator.setDuration(3000); // animator.setRepeatCount(5);//动画执行的次数 //animator.setRepeatMode(ValueAnimator.REVERSE);//动画执行的模式 animator.start(); } //透明动画 public void alpha(View view) { //参数1...控件,,参数2...动画的类型,,,参数3..起始清晰度,,,参数4...结束清晰度 ObjectAnimator animator = ObjectAnimator.ofFloat(imageView, "alpha", 0, 1); animator.setDuration(3000); animator.start(); } //缩放动画 public void scale(View view) { //参数1...控件,,参数2...动画的类型,,,参数3..起始图片大小,,,参数4...结束图片大小 ObjectAnimator animator = ObjectAnimator.ofFloat(imageView, "scaleX", 0, 2); ObjectAnimator animator1 = ObjectAnimator.ofFloat(imageView, "scaleY", 0, 2); animator.setDuration(3000); animator.start(); animator1.setDuration(3000); animator1.start(); } //组合动画 public void zuhe_02(View view) { ObjectAnimator y = ObjectAnimator.ofFloat(imageView, "y", 0, 250); ObjectAnimator scaleX = ObjectAnimator.ofFloat(imageView, "scaleX", 0.5f, 2); ObjectAnimator scaleY = ObjectAnimator.ofFloat(imageView, "scaleY", 0.5f, 2); ObjectAnimator alpha = ObjectAnimator.ofFloat(imageView, "alpha", 0.5f, 1.0f); ObjectAnimator rotationX = ObjectAnimator.ofFloat(imageView, "rotationX", 0, 360); ObjectAnimator rotationY = ObjectAnimator.ofFloat(imageView, "rotationY", 0, 360); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(y).with(scaleX).with(scaleY).with(alpha); animatorSet.setDuration(5000); animatorSet.start(); }}
阅读全文
0 0
- Android的动画布局
- android 的动画
- Android的animation(动画)
- Android ViewFlipper的动画
- android 的动画类型
- Android动画的使用
- android 动画的实现
- Android 动画的播放
- Android的动画
- Android的动画总结
- Android 动画的案例
- android 的动画类型
- Android动画的优化
- Android的animation动画
- android的动画
- android的属性动画
- Android动画的应用
- android动画的实现
- Web of Science爬虫实战(模拟浏览器)
- 树莓派引脚相对位置示意图
- 瞎写点什么
- 【WebGL】茶壶和光照
- uva10142
- android的动画
- Unity 脚本接口值Path
- struts2框架搭建
- Scikit-learn——Naive Bayes
- Eclipse 设置新建jsp文件的默认模板
- Vocabulary
- VS编译报错 error MSB6006: “cmd.exe” exited with code 1.
- 7.5
- 。。。