public class shuxingActivity extends AppCompatActivity {
private ImageView image;
private Button button;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shuxing);
//初始化
image = findViewById(R.id.image);
float curTranslationY = image.getTranslationY();
//放大
ObjectAnimator scaleY = ObjectAnimator.ofFloat(image, "scaleY", 1f, 2.5f, 1f);
ObjectAnimator scaleX = ObjectAnimator.ofFloat(image, "scaleX", 1f, 2.5f, 1f);
//平移
ObjectAnimator translationY
= ObjectAnimator.ofFloat(image, "translationY",
curTranslationY, curTranslationY + 500f);
AnimatorSet animSet = new AnimatorSet();
animSet.play(scaleY).with(scaleX).after(translationY);
animSet.setDuration(3000);
animSet.start();
}
}