JayceLi  

1,在Activity的onCreate中设置:

1         getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
2         getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);

2,在需要显示和隐藏的时候调用:

 1     private void hideStatusBar() {
 2         WindowManager.LayoutParams attrs = getWindow().getAttributes();
 3         attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
 4         getWindow().setAttributes(attrs);
 5     }
 6 
 7     private void showStatusBar() {
 8         WindowManager.LayoutParams attrs = getWindow().getAttributes();
 9         attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
10         getWindow().setAttributes(attrs);
11     }

即可。

posted on 2012-11-15 18:55  JayceLi  阅读(1782)  评论(2编辑  收藏  举报