我有5张图片,我想要img1& img2同时闪烁3秒,然后img3& img4同时闪烁3秒。但是,我希望img5保持静态3秒,然后整个过程从头再次开始。
我的部分代码:
public class MainActivity extends Activity
{
...
img1=(ImageView) findViewById(R.id.imageView1);
img2=(ImageView) findViewById(R.id.imageView2);
img3=(ImageView) findViewById(R.id.imageView3);
img4=(ImageView) findViewById(R.id.imageView4);
img5=(ImageView) findViewById(R.id.imageView5);
img2.setVisibility(View.GONE);
img3.setVisibility(View.GONE);
....
anim = new AlphaAnimation(0.0f, 1.0f);
anim.setDuration(500); //You can manage the time of the blink with this parameter
anim.setStartOffset(30);
anim.setRepeatMode(Animation.REVERSE);
anim.setRepeatCount(20);
...
img1.startAnimation(anim);
AnimationListener animListener = new AnimationListener()
{
@Override
public void onAnimationEnd(Animation arg0) {
// TODO Auto-generated method stub
img1.setVisibility(View.GONE);
img2.setVisibility(View.VISIBLE);
img2.startAnimation(anim2);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationStart(Animation animation) {
}
};
}
答案 0 :(得分:2)
使用Handler
将img5静态保持3秒钟,然后开始动画。
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
// animateImg5();
}
}, 3000);