android去除標題欄及狀態列
阿新 • • 發佈:2019-01-22
總共有三種方式:
1)在程式碼中實現
在onCreate()方法中新增下面的的程式碼(一定要寫在setContentView()前面):
//去掉標題欄
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//設定全屏
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
2)在清單檔案AndroidManifest.xml檔案裡的application下修改
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
3)在style.xml檔案中定義
<style name="AppTheme.NoActionBar">
<!-- 隱藏標題欄 -->
<item name="windowNoTitle">true</item>
<!-- 隱藏狀態列 -->
<item name="android:windowFullscreen">true</item>
</style>
然後在AndroidManifest.xml檔案裡的application下引用
android:theme="@style/AppTheme.NoActionBar"