android 取消activity标题栏的显示

如果继承的是AppCompatActivity这个是自带标题栏的,以下三种方法不起作用

判断是否显示如果显示则隐藏

if (getSupportActionBar()!=null){
   getSupportActionBar().hide();
}

网上大部分的解决办法都是千篇一律的为以下三点:

1. AndroidManifest.xml 清单中在application中添加
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
2. 自定义style
<style name="Theme.AppStartLoadTranslucent" parent="AppTheme">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowNoTitle">true</item>
</style>

同样也是AndroidManifest.xml 清单中在application中添加
android:theme="@style/Theme.AppStartLoadTranslucent"

3. 程序中填写(不推荐)

写在 setContentView方法之前

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN
WindowManager.LayoutParams.FLAG_FULLSCREEN);

猜你喜欢

转载自blog.csdn.net/zhaohan___/article/details/87272279