-1

我想做一个安卓知识问答游戏,到目前为止我还没有遇到什么大问题。我已经设置了所有按钮,我需要为它们设置动画,以便当它们被点击时,红色或绿色(取决于答案是对还是错)将开始在按钮上闪烁。

4

1 回答 1

0

您可以使用动画类

    final Animation animation = new AlphaAnimation(1, 0); // Change alpha from fully visible to invisible
    animation.setDuration(500); // duration - half a second
    animation.setInterpolator(new LinearInterpolator()); // do not alter animation rate
    animation.setRepeatCount(Animation.INFINITE); // Repeat animation infinitely
    animation.setRepeatMode(Animation.REVERSE); // Reverse animation at the end so the button will fade back in
    final Button btn = (Button) findViewById(R.id.your_btn);
    btn.startAnimation(animation);

礼貌:https ://stackoverflow.com/a/4852468/931982

于 2013-06-02T16:01:08.713 回答