1.要activity的
java
setContentView(R.layout.video_main);
2.以前加上ide
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN); getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
3.再用post
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);//顯示狀態欄 getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);//隱藏狀態欄
可是,我發現用上面那(2的)兩句話,把我videoview中用的mediacoontroller的進度條給屏蔽了spa
因此,能夠把那兩句話改用code
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
我用的是viewpager,中間頁裏放了videoview,因此會發現,videoview上顯示正常了,可是左右兩頁顯示不正常了get
能夠加上it
//顯示狀態欄,Activity不全屏顯示(恢復到有狀態的正常狀況) class
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
因此能夠在監聽滑到第幾頁layout
@Override public void onPageSelected(int arg0) { if (arg0 == 0) { getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); }else if (arg0 == 2){ getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); }else{ getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); new Handler().postDelayed(new Runnable() { @Override public void run() { getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } },1000); } }
補充:透明任務欄
margin
在View中添加定義了兩個Flag。 // 徹底透明任務欄 public static final int SYSTEM_UI_FLAG_TRANSPARENT_STATUS_BAR = 0x00000010; //半透明任務欄 public static final int SYSTEM_UI_FLAG_TRANSLUCENT_STATUS_BAR = 0x00000020;有些應用須要設置的時候,在須要的UI界面設置:getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_TRANSPARENT_STATUS_BAR);應用退出無需作任何處理,系統會恢復默認。