How to hide ActionBar and NavigationBar after a certain delay time?

♀尐吖头ヾ 提交于 2019-12-10 21:06:28

问题


I would hide navigation bar and action bar of my app after some second that display don't get touched, and expand current view to fullscreen. Then if user touch the screen (or better if he swipe down), make visible both again. How to?


回答1:


You can use a Handler to delay certain actions.

 Handler h = new Handler();

 h.postDelayed(new Runnable() {

     @Override
     public void run() {
         // DO DELAYED STUFF
         getActionBar().hide();
     }
 }, delaytime); // e.g. 3000 milliseconds

The actions you take inside the run() method will be executed after the delay-time you set.




回答2:


If you are using Eclipse, just create a new project and select "Fullscreen Activity": this is a good example on how to do what you want.



来源:https://stackoverflow.com/questions/18674670/how-to-hide-actionbar-and-navigationbar-after-a-certain-delay-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!