ImageView image = findViewById(R.id.image);
findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//缩小1倍
ScaleAnimation scaleAnim = new ScaleAnimation(1f, 0.5f, 1f, 0.5f, image.getWidth() / 2f, image.getHeight() / 2f);
scaleAnim.setDuration(1000);
scaleAnim.setFillAfter(true);
image.startAnimation(scaleAnim);
}
});
findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//放大1倍
ScaleAnimation scaleAnim = new ScaleAnimation(0.5f, 1f, 0.5f, 1f, image.getWidth() / 2f, image.getHeight() / 2f);
scaleAnim.setDuration(1000);
scaleAnim.setFillAfter(true);
image.startAnimation(scaleAnim);
}
});