这是我的代码.这里动画后图像尺寸减小了.当我再次单击
ImageView时,我只想要
ImageView的原始大小.我是初学者,所以我需要一些帮助.我尝试过类似的东西:
football.animate().scaleX(1f).scaleY(1f).setDuration(1000).start();
在setonclicklistener的开头,但这不起作用.
提前致谢
football.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ValueAnimator animator = ValueAnimator.ofFloat(0, 1);
// values from 0 to 1
animator.setDuration(1000); // 5 seconds duration from 0 to 1
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener()
{
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float value = ((Float) (animation.getAnimatedValue()))
.floatValue();
// Set translation of view here. Position can be calculated
// out of value. This code should move the view in a half circle.
football.setTranslationX((float)(100.0 * Math.sin(value*Math.PI)));
football.setTranslationY((float)(400.0 * Math.cos(value*Math.PI)));
}
});
animator.start();
football.setScaleType(ImageView.ScaleType.CENTER);
//here the scaling is performed
football.animate().scaleX(0.4f).scaleY(0.4f).setDuration(1000).start();
}
});