Activity設置全屏顯示(隱藏標題欄和狀態欄):java
方法一:android
在Activity oncreate()方法中ui
//隱去電池等圖標和一切修飾部分(狀態欄部分) this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);// 隱去標題欄 this.requestWindowFeature(Window.FEATURE_NO_TITLE);this
方法二:spa
在AndroidManifest.xml 中設置隱去標題欄, 隱去狀態欄 android:theme="@android :style/Theme.NoTitleBar.Fullscreen".net
以上方法適用於android4.0如下版本,在android4.0以上版本是底部有虛擬按鍵欄,這是須要使用以下方法code
if(android.os.Build.VERSION.SDK_INT>=14){ getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); }else if(android.os.Build.VERSION.SDK_INT>=16){ getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); }
方法三:
設置style,設置啓動時沒有標題欄xml
<style name="AppBaseTheme" parent="Theme.AppCompat.Light"></style> <!-- Application theme. --> <style name="AppTheme" parent="AppBaseTheme"> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowIsTranslucent">true</item> <item name="android:windowNoTitle">true</item> </style>