Java 隐藏或删除特定活动的操作栏 | 安卓

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41511214/
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-11 23:27:00  来源:igfitidea点击:

Hide or remove Action Bar on specific Activity | Android

javaandroidandroid-activityandroid-actionbar

提问by Maxim

How I can remove Action Bar on specific activity not for all application, for example I have Sign Up activity and for this activity I want to remove Action Bar

如何删除特定活动的操作栏而不是所有应用程序,例如我有注册活动,对于此活动,我想删除操作栏

回答by firegloves

from within your activity:

从您的活动中:

getActionBar().hide();

or

或者

getSupportActionBar().hide();

I would suggest to migrate to ToolBar, new Android API for the same purpose. The main benefit of ToolBar is that you can treat it like other views, it guarantees to you a more flexible approach.

我建议迁移到 ToolBar,出于同样的目的,新的 Android API。ToolBar 的主要好处是您可以像对待其他视图一样对待它,它保证为您提供更灵活的方法。

回答by Montassir Ld

If you have an ActionBar, you can use getActionBar().hide();
If you have a SupportActionBar, you can use getSupportActionBar().hide();

如果你有一个 ActionBar,你可以使用getActionBar().hide();
如果你有一个 SupportActionBar,你可以使用getSupportActionBar().hide();

回答by Yessine Mahdouani

In your AndroidManifest.xmluse NoActionBar theme for your Activity like this:

在您的AndroidManifest.xml 中,为您的 Activity 使用 NoActionBar 主题,如下所示:

<activity android:name=".SignUpActivity"
          android:theme="@style/AppTheme.NoActionBar"/>

and in your styles.xml

并在你的styles.xml

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

回答by Enam Butt

Remove Action Bar on specific Activity go to Activity java file here your Activity class extends with AppCompatActivityremove the AppCompatActivity and extends with Activityand go to xml file and select Theme NoTitleBaror go to Manifests file select your Activity and add Theme on your Activity android:theme="@android:style/Theme.NoTitleBar"/>

删除特定 Activity 上的 Action Bar 转到 Activity java 文件,您的 Activity 类使用AppCompatActivity扩展,删除 AppCompatActivity 并使用Activity扩展,然后转到 xml 文件并选择 Theme NoTitleBar或转到 Manifests 文件,选择您的 Activity 并在您的 Activity android上添加主题: theme="@android:style/Theme.NoTitleBar"/>

回答by Laurelton Studios

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

回答by Abduhafiz

For kotlin you can use supportActionBar?.hide()

对于 kotlin,您可以使用 supportActionBar?.hide()