如何制作一个ImageView popin

时间:2018-04-07 11:00:35

标签: java android animation popup android-imageview

我的布局看起来像这样

上面有两个线性布局(黑色),以这种方式排列,形成十字架。

现在十字架有四个部分,每个部分有两个图像。

我有一个int variable,其值介于0 to 4之间。此变量的值将不时变化(可能每1秒)

所以基本上我想要实现的是隐藏屏幕开始处的所有图像,每2秒弹出一次图像。

假设int variable的值为\

值= 1然后弹出1,2图像

值= 2然后弹出3,4图像

值= 3然后弹出5,6图像

值= 4然后弹出7,8图像

现在每次弹出一个新图像时,我都希望隐藏以前的图像。

任何人都可以帮我实现这个目标吗?

1 个答案:

答案 0 :(得分:1)

您可以使用动画弹出图像。要每2秒弹出一次图像,您可以设置线程。以下可能对您有帮助。

每10秒钟调用一次功能。

Handler handler = new Handler();
int delay = 1000; //milliseconds

handler.postDelayed(new Runnable(){
    public void run(){
        //do something
        handler.postDelayed(this, delay);
    }
}, delay);

用于动画/闪烁图像

Animation animation = new AlphaAnimation(1, 0);
    animation.setDuration(1000); 
    animation.setInterpolator(new LinearInterpolator()); 
    animation.setRepeatCount(Animation.INFINITE); 
    animation.setRepeatMode(Animation.REVERSE); 
    imageButton.startAnimation(animation);