android view点击缩放,android – 如何在ViewPropertyAnimator缩放后将View返回到原始大小?...

这是我的代码.这里动画后图像尺寸减小了.当我再次单击

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();

}

});

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值