Java 视图中的动画列表

Java 视图中的动画列表,java,android,android-animation,Java,Android,Android Animation,单击时,我希望在ImageButton中执行以下操作: 1-是原来的两倍 2-在第1步之后,开始缩小,直到它变成一个点,同时使用淡出效果 3-让它隐形 ImageButton.setImageVisibility(gone); 我怎样才能做到这一点呢?对于这种使用缩放图像的方式,它将使图像按钮的大小增加一倍 ScaleAnimation setSizeForTop = new ScaleAnimation(1, 2, 1, 2); 现在, 用于缩小尺寸 setSizeForTop = n

单击时,我希望在ImageButton中执行以下操作:

1-是原来的两倍

2-在第1步之后,开始缩小,直到它变成一个点,同时使用淡出效果

3-让它隐形

 ImageButton.setImageVisibility(gone);

我怎样才能做到这一点呢?

对于这种使用缩放图像的方式,它将使图像按钮的大小增加一倍

ScaleAnimation  setSizeForTop = new ScaleAnimation(1, 2, 1, 2);
现在,

用于缩小尺寸

setSizeForTop = new ScaleAnimation(1, .5f, 1, .5f); 
对于淡出效果,我们使用

Animation fadeOut = new AlphaAnimation(1, 0);
fadeOut.setInterpolator(new AccelerateInterpolator()); //and this
fadeOut.setStartOffset(1000);
fadeOut.setDuration(1000);

AnimationSet animation = new AnimationSet(false); //change to false
animation.addAnimation(fadeIn);
animation.addAnimation(fadeOut);
this.setAnimation(animation);
看不见

 ImageButton.setImageVisibility(gone);

请看一下在蜂巢中引入的ValueAnimator(但在名为NineolandRoid的库中也有后端口)

在按钮onClick中,您可以从XML加载动画,或者以编程方式创建动画,然后启动它

可以使用一个动画设置一个接一个地运行多个动画

以下是一些(未经测试的)示例代码:

    //set up the scale and fade animation set
    AnimatorSet scaleAndFadeSet = new AnimatorSet();
    scaleAndFadeSet.playTogether( ValueAnimator.ofFloat(myButton, "alpha", 1.0f, 0f), ObjectAnimator.ofFloat(myButton, "scale", 2.0f, 0f));

    // the top level animation set
    AnimatorSet set = new AnimatorSet();
    set.playTogether(ObjectAnimator.ofFloat(myButton, "scale", 0, 2.0f),scaleAndFadeSet);
    set.setDuration(1000);// 1s animation
    set.start();