去除actin bar

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/huangxin388/article/details/77432044

        之前用eclipse开发安卓,想去除action bar只需要在setContentView(R.layout.activity_main);之前写上一行requestWindowFeature(Window.FEATURE_NO_TITLE);就行了。

 可是最近用android studio开发,再用这种方法程序反而crash掉了。又去网上百度了几种方法

1、

将them设置为android:theme=”@android:style/Theme.Light.NoTitleBar”,程序继续crash


2、

在MainActivity中增加以下代码

actionBar = getActionBar();
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);

程序依旧crash

最后,哈哈,我将主题换为

android:theme="@style/Theme.AppCompat.Light.NoActionBar"
(对应的黑色主题为android:theme="@style/Theme.AppCompat.NoActionBar"
程序正常运行,并且没有action bar
 
 

上面的topbar是自己写的,不是系统提供的actin bar.

希望能帮到和我遇到相同问题的人。

按道理讲用其他方法程序也不应该崩溃,我想原因大概是不同的版本支持不同的主题吧。

等以后明白了再补充。













猜你喜欢

转载自blog.csdn.net/huangxin388/article/details/77432044
bar