属性动画
来源:互联网 发布:mysql应用 编辑:程序博客网 时间:2024/05/16 04:42
/**
* 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
- 属性动画
- 属性动画
- 属性动画
- 属性动画
- 属性动画
- 属性动画
- 属性动画
- 属性动画
- 属性动画
- 属性动画
- 属性动画
- 属性动画
- 属性动画
- 属性动画
- 属性动画
- 属性动画
- 属性动画
- 属性动画
- 判断是否为平衡二叉树
- Linux命令每日学之Ping
- 应用程序运行慢(cpu util 高)的一种可能原因
- 基于dockerfile的运维工具ansible和nginx安装
- FreeBASIC学习笔记——第09章 预编译
- 属性动画
- 如何使用charles代理转发请求
- 剑指offer——面试题:把字符串转换为整数
- leetcode 3 Longest Substring Without Repeating Characters
- leetcode 592. Fraction Addition and Subtraction C++的stringstream的一个很好的示例
- nginx四 之缓存模块
- Access数据库的模糊查询
- Java序谈之List接口、Vector类,LinkedList类
- C++——动态数组