一、继承AppCompatActivity情况去掉ActionBar
1、manifest中设置:在application中设置,或者指定activity设置()。
//状态栏背景黑色字体白色
android:theme="@style/Theme.AppCompat.NoActionBar"
//状态栏背景灰色字体白色
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"
2、代码实现:在setContentView()之后设置:
getSupportActionBar().hide();
3、自定义style
<style name="ActivityTheme" parent="Theme.AppCompat.Light">
<item name="windowActionBar">false</item>//无ActionBar
<item name="windowNoTitle">true</item> //无标题
<item name="android:windowFullscreen">true</item> //全屏
</style>
//第一第二属性必须同时使用,否则挂了
二、全屏设置:
getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN ,WindowManager.LayoutParams. FLAG_FULLSCREEN);
本文详细介绍如何在Android应用中去除ActionBar以及实现全屏显示的方法。包括在manifest文件中设置主题,通过代码隐藏ActionBar,以及自定义样式实现无ActionBar及全屏效果。适用于希望优化UI界面的开发者。
7679

被折叠的 条评论
为什么被折叠?



