Android Studio - 删除操作栏

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24742732/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 08:40:42  来源:igfitidea点击:

Android Studio - Action Bar remove

androidxmlandroid-actionbarmanifest

提问by iYonatan

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

我正在尝试删除/禁用 ActionBar。我试图放入清单:

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

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

它不起作用。它不会删除 ActionBar。请帮我。谢谢。

回答by malamute84

I had this issue too. I went to styles.xmland changed

我也有这个问题。我去了styles.xml并改变了

parent="Theme.AppCompat.Light.DarkActionBar" 

to

parent="Theme.AppCompat.Light.NoActionBar"

and that removed it from all my activities.

并将其从我的所有活动中删除。

回答by goonerDroid

in your oncreate()method use this

在你的oncreate()方法中使用这个

getActionBar().hide();

If your minSdkVersionis 10 or lower, instead use:

如果您minSdkVersion是 10 或更低,请改用:

getSupportActionBar().hide();

回答by reza.cse08

You can try this. It works for me

你可以试试这个。这个对我有用

Add it in style.xml

在 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.

并使用 manifest.xml 中的样式。

android:theme="@style/AppTheme.NoActionBar"

回答by Ashikur Rahman

getActionBar().hide();

I think this should work.

我认为这应该有效。

回答by ASIF ALI

For android studio You can go to styles.xml and change

对于android studio你可以去styles.xml并改变

parent="Theme.AppCompat.Light.DarkActionBar"

to

parent="Theme.AppCompat.Light.NoActionBar" 

and in Eclipse it can be changed in manifest file

在 Eclipse 中,它可以在清单文件中更改

  <activity
        android:name="com.ExcellenceTech.webview.MainActivity"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen" >

回答by Anjani kumar joshi

You hide action bar by with different ways.

您可以通过不同的方式隐藏操作栏。

1.action bar hidden through the manifest xml file (non Java Programming), then the easy way is to add the following attribute in Activity tag:

1.action bar通过manifest xml文件隐藏起来(非Java编程),那么简单的方法就是在Activity标签中添加如下属性:

 android:theme="@style/Theme.NoActionBar"

If custom Theme is created then it is convenient to create another style extending the custom theme.

如果创建了自定义主题,那么创建另一个扩展自定义主题的样式会很方便。

 <item name="android:windowActionBar">false</item>
 <item name="android:windowNoTitle">true</item>

or

或者

ActionBar actionBar = getActionBar(); OR getSupportActionBar();
actionBar.hide();

getSupportActionBar().hide(); 
  or 
getActionBar().hide();

回答by JavaScrap

In AndroidManifest.xml and acitivity section put this code.

在 AndroidManifest.xml 和 acitivity 部分放置此代码。

android:theme="@style/Theme.AppCompat.Light.NoActionBar"

回答by Vimukthi Sineth

getActionBar().hide();

or

或者

getSupportActionBar().hide();

But the change might not appear in the xml design.

但是更改可能不会出现在 xml 设计中。