使 ImageView 在设定的时间内可见 [英] Make ImageView visible for set amount of time

查看:29
本文介绍了使 ImageView 在设定的时间内可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 xml 布局文件中设置了一个 onClick 方法,该方法触发手机振动 100 毫秒,此时我将 ImageView Visibility 设置为可见,以便可以看到它.我希望 ImageView 在振动停止后重新设置为消失.我该怎么做?

I have an onClick method set in the xml layout file that triggers the vibration of the phone for 100ms at this point I have the ImageView Visibility set to visible so it can be seen. I want the ImageView to be set back to gone again when the vibration has stopped. How do I go about this?

推荐答案

可以同时启动这个方法:

You can start this method at the same time:

public void timerDelayRemoveView(float time, final ImageView v) {
    Handler handler = new Handler(); 
    handler.postDelayed(new Runnable() {           
        public void run() {                
            v.setVisibility(View.GONE);      
        }
    }, time); 
}

这篇关于使 ImageView 在设定的时间内可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆