Android Studio - Action Bar remove

2019-03-11 05:38发布

I'm trying to remove/disable the ActionBar. I tried to put in the Manifest:

<activity
    ...
    android:theme="@android:style/Theme.NoTitleBar"
</activity>

and it doesn't work. It doesn't remove the ActionBar. Please help me. Thanks.

8条回答
爷的心禁止访问
2楼-- · 2019-03-11 06:01
getActionBar().hide();

I think this should work.

查看更多
Deceive 欺骗
3楼-- · 2019-03-11 06:10

I had this issue too. I went to styles.xml and changed

parent="Theme.AppCompat.Light.DarkActionBar" 

to

parent="Theme.AppCompat.Light.NoActionBar"

and that removed it from all my activities.

查看更多
放荡不羁爱自由
4楼-- · 2019-03-11 06:13

You can try this. It works for me

Add it in style.xml

<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.DarkActionBar">
      <item name="windowActionBar">false</item>
      <item name="windowNoTitle">true</item>
      <item name="android:windowFullscreen">true</item>
</style>

and use the style at manifest.xml.

android:theme="@style/AppTheme.NoActionBar"
查看更多
我只想做你的唯一
5楼-- · 2019-03-11 06:15

In AndroidManifest.xml and acitivity section put this code.

android:theme="@style/Theme.AppCompat.Light.NoActionBar"
查看更多
小情绪 Triste *
6楼-- · 2019-03-11 06:16
getActionBar().hide();

or

getSupportActionBar().hide();

But the change might not appear in the xml design.

查看更多
我欲成王,谁敢阻挡
7楼-- · 2019-03-11 06:22

in your oncreate() method use this

getActionBar().hide();

If your minSdkVersion is 10 or lower, instead use:

getSupportActionBar().hide();
查看更多
登录 后发表回答