问题描述
我有一个带有 3 个单选按钮的单选组(单选按钮有一个图像作为背景)。当我单击一个按钮时,按钮会随着一点动画而缩放。 它目前正在工作。但是如果单击另一个单选按钮,我想让动画停止。
我不知道在我的代码中在哪里放置条件:
RadioButton radioButton1 = findViewById(R.id.lives_radiob_1);
RadioButton radioButton2 = findViewById(R.id.lives_radiob_3);
RadioButton radioButton3 = findViewById(R.id.lives_radiob_5);
radiogroup.setonCheckedchangelistener(new RadioGroup.OnCheckedchangelistener() {
@Override
public void onCheckedChanged(RadioGroup group,int checkedId) {
if (checkedId == R.id.lives_radiob_1){
radioButtonAnimate(radioButton1);
}else if (checkedId == R.id.lives_radiob_2){
radioButtonAnimate(radioButton2);
}else if (checkedId == R.id.lives_radiob_3){
radioButtonAnimate(radioButton3);
}
}
});
public void radioButtonAnimate(RadioButton radiobutton){
ObjectAnimator scaleDown = ObjectAnimator.ofPropertyValuesHolder(
radiobutton,PropertyValuesHolder.ofFloat("scaleX",0.4f),PropertyValuesHolder.ofFloat("scaleY",0.4f));
scaleDown.setDuration(500);
scaleDown.setRepeatMode(ValueAnimator.REVERSE);
scaleDown.setRepeatCount(ValueAnimator.INFINITE);
scaleDown.start();
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)