xuanzhuan = findViewById(R.id.xuanzhuan);
suofang = findViewById(R.id.suofang);
pingyi = findViewById(R.id.pingyi);
jianbian = findViewById(R.id.jianbian);
object = findViewById(R.id.object);
value = findViewById(R.id.value);
iv = findViewById(R.id.iv);
value.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ValueAnimator valueAnimator = ValueAnimator.ofInt(0,300,0,150,0);
valueAnimator.setDuration(5000);
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
int animatedValue = (int) valueAnimator.getAnimatedValue();
iv.layout(animatedValue,animatedValue,animatedValue+ iv.getWidth(),animatedValue+ iv.getHeight());
}
});
valueAnimator.start();
}
});
xuanzhuan.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(iv, "rotationX", 0f, 360f);
objectAnimator.setDuration(5000);
objectAnimator.start();
}
});
suofang.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(iv, "scaleX",3f,0f,3f);
objectAnimator.setDuration(5000);
objectAnimator.start();
}
});
pingyi.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(iv, "translationY",0f,300f,150f,0f);
objectAnimator.setDuration(5000);
objectAnimator.start();
}
});
jianbian.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(iv, "alpha",0f,1f);
objectAnimator.setDuration(5000);
objectAnimator.start();
}
});
object.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ObjectAnimator alpha = ObjectAnimator.ofFloat(iv, "alpha",0f,1f);
ObjectAnimator translationY = ObjectAnimator.ofFloat(iv, "translationY",0f,300f,150f,0f);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.play(alpha)
.with(translationY);
animatorSet.setDuration(5000);
animatorSet.start();
}
});