属性动画
来源:互联网 发布:cs1.6显示网络 编辑:程序博客网 时间:2024/06/06 09:36
/**
* http://blog.csdn.net/lmj623565791/article/details/38067475
*/
public class MainActivity extends AppCompatActivity {
private ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView = findViewById(R.id.image_view);
}
public void trans(View view) {
ObjectAnimator animator = ObjectAnimator.ofFloat(imageView, "y", 0, 1300);
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) {
ObjectAnimator animator = ObjectAnimator.ofFloat(imageView, "rotationY", 0, 360);
animator.setDuration(3000);
animator.start();
}
public void alpha(View view) {
ObjectAnimator animator = ObjectAnimator.ofFloat(imageView, "alpha", 0, 1);
animator.setDuration(3000);
animator.start();
}
public void scale(View view) {
ObjectAnimator animator = ObjectAnimator.ofFloat(imageView, "scaleX", 0, 2);
animator.setDuration(3000);
animator.start();
}
@SuppressLint("ObjectAnimatorBinding")
public void zuhe_01(View view) {
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(imageView, "abc", 0, 1);
objectAnimator.setDuration(4000);
objectAnimator.start();
//动画的属性值不停更新的方法
objectAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
//属性的值
float animatedValue = (float) valueAnimator.getAnimatedValue();
imageView.setScaleX(animatedValue);
imageView.setScaleY(animatedValue);
imageView.setAlpha(animatedValue);
}
});
}
public void zuhe_02(View view) {
ObjectAnimator y = ObjectAnimator.ofFloat(imageView, "y", 0, 10, 200, 250, 500, 1000, 1100, 1300);
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).before(scaleX);
animatorSet.play(scaleX).with(scaleY);
animatorSet.play(alpha).with(scaleY);
animatorSet.play(rotationX).with(alpha).with(rotationY);*/
animatorSet.play(y).with(scaleX).with(scaleY).with(alpha);
animatorSet.setDuration(5000);
animatorSet.start();
animatorSet.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
}
@Override
public void onAnimationEnd(Animator animator) {
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
});
}
}
* http://blog.csdn.net/lmj623565791/article/details/38067475
*/
public class MainActivity extends AppCompatActivity {
private ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView = findViewById(R.id.image_view);
}
public void trans(View view) {
ObjectAnimator animator = ObjectAnimator.ofFloat(imageView, "y", 0, 1300);
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) {
ObjectAnimator animator = ObjectAnimator.ofFloat(imageView, "rotationY", 0, 360);
animator.setDuration(3000);
animator.start();
}
public void alpha(View view) {
ObjectAnimator animator = ObjectAnimator.ofFloat(imageView, "alpha", 0, 1);
animator.setDuration(3000);
animator.start();
}
public void scale(View view) {
ObjectAnimator animator = ObjectAnimator.ofFloat(imageView, "scaleX", 0, 2);
animator.setDuration(3000);
animator.start();
}
@SuppressLint("ObjectAnimatorBinding")
public void zuhe_01(View view) {
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(imageView, "abc", 0, 1);
objectAnimator.setDuration(4000);
objectAnimator.start();
//动画的属性值不停更新的方法
objectAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
//属性的值
float animatedValue = (float) valueAnimator.getAnimatedValue();
imageView.setScaleX(animatedValue);
imageView.setScaleY(animatedValue);
imageView.setAlpha(animatedValue);
}
});
}
public void zuhe_02(View view) {
ObjectAnimator y = ObjectAnimator.ofFloat(imageView, "y", 0, 10, 200, 250, 500, 1000, 1100, 1300);
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).before(scaleX);
animatorSet.play(scaleX).with(scaleY);
animatorSet.play(alpha).with(scaleY);
animatorSet.play(rotationX).with(alpha).with(rotationY);*/
animatorSet.play(y).with(scaleX).with(scaleY).with(alpha);
animatorSet.setDuration(5000);
animatorSet.start();
animatorSet.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
}
@Override
public void onAnimationEnd(Animator animator) {
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
});
}
}
阅读全文
0 0
- 属性动画
- 属性动画
- 属性动画
- 属性动画
- 属性动画
- 属性动画
- 属性动画
- 属性动画
- 属性动画
- 属性动画
- 属性动画
- 属性动画
- 属性动画
- 属性动画
- 属性动画
- 属性动画
- 属性动画
- 属性动画
- 关于Python中的import(一)
- 几个连接HiveServer的客户端界面工具
- faster rcnn报错:TypeError: slice indices must be integers or None or have an __index__ method
- 禁用 Python GC,Instagram 性能提升10%
- Android蓝牙开发与蓝牙模块进行通讯(基于eclipse)
- 属性动画
- PostgreSQL学习手册(表的继承和分区)
- c语言 总结操作符使用 理解二进制存储
- 揭开Faiss的面纱 探究Facebook相似性搜索工具的原理
- etcdctl 使用说明
- Unity中一些优化方案
- 推荐一款任务调度的开源方案
- MySQL时间相关操作
- Kotlin与Android的奇妙之旅(一)