4 个答案:
答案 0 :(得分:0)
首先定义2个Animation和Button对象,然后为Button创建一个On Click侦听器,并在其中编写以下代码:
//here i define :Button btnoff
//Animation animation1
//set on click listener in oncreate
btnOff.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
animation1 = new ScaleAnimation(0,2,1,1,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
animation1.setDuration(1200);
btnOff.startAnimation(animation1);}
});
您可以在此link中了解更多信息。
答案 1 :(得分:0)
我认为您可以将this库用于Button 2动画。
为了在点击另一个按钮时发生,只需从View.performClick() onClick()方法调用Button 2 Button 1。
答案 2 :(得分:0)
平滑的动画效果,可以使用ObjectAnimtor。
答案 3 :(得分:0)
// scale down button2 at the start of an activity
btn2.setScaleX(0.1f);
// on the click of button 1 let the button2 scale
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
btn2.animate()
.scaleX(4.0f)
.setDuration(1000)
.setInterpolator(new OvershootInterpolator(2.0f)) //Will give bounce effect to the scaling
.start();
}
});