有这样一个需求,需要点击图片放大缩小动画,效果:
我们借助Android自带动画Animation ,很容易实现
初始化对象
Animation animation;
private ImageView iv_good;
animation= AnimationUtils.loadAnimation(this, R.anim.anim_small);
按钮点击事件
iv_good.setOnClickListener(newView.OnClickListener() {
@Override
publicvoid onClick(Viewview) {
iv_good.startAnimation(animation);
}
});
属性动画
res/anim/anim_small.xml
android:fillAfter="false">
android:duration="300"
android:fromXScale="1"
android:fromYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="2"
android:toYScale="2"/>
android:duration="300"
android:fromXScale="1"
<