方式1
styles里增加:
<item name="android:windowFullscreen">true</item>
<item name="windowNoTitle">true</item>
完整代码样例:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowFullscreen">true</item>
<item name="windowNoTitle">true</item>
</style>
Manifest定义:
<application
...
android:theme="@style/AppTheme">
</application>
方式2
activity代码中设置(在setContentView方法前调用):
supportActionBar?.hide()
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
网友评论