使 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);
}
相关文章