如何删除android studio中的标题栏?

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

How do I remove the title bar in android studio?

androidandroid-layoutandroid-studio

提问by Jonas Otto

In my app there is this title bar at the top where the overflow menu would be, but I don't need settings and only have one screen. When I change the theme like described in many other questions I get the old 2.2 theme. I want to have the modern theme just without the bar at the top.

在我的应用程序中,溢出菜单所在的顶部有这个标题栏,但我不需要设置并且只有一个屏幕。当我像许多其他问题中描述的那样更改主题时,我得到了旧的 2.2 主题。我想要现代主题,只是没有顶部的酒吧。

回答by Mr. Torres

Go to styles.xml and change .DarkActionBarfor .NoActionBar

转到styles.xml 并更改.DarkActionBar.NoActionBar

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
</style>

becomes

变成

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
</style>

if colors are irrelevant to your app, you can actually go for

如果颜色与您的应用程序无关,您实际上可以选择

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar" />

回答by Tarek Ezzat Abdallah

In the manifest file Change:

在清单文件中更改:

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

回答by Ivo Robotnik

this.requestWindowFeature(Window.FEATURE_NO_TITLE);

works in onCreate()when put before setContentView()is invoked.

在调用onCreate()put before 时起作用setContentView()

otherwise it crashes

否则会崩溃

回答by Kamesh Kumar Singh

In styles.xmlfile, change DarkActionBarto NoActionBar

styles.xml文件,更改DarkActionBarNoActionBar

    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>

回答by Manmohan Kumar

Check this

检查这个

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

回答by Roger Casagrande

This was working for me on values/styles.xmladd items:

这对我来说在values/styles.xml添加项目时有用:

       `<item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>`

回答by XIII

In the manifest file change to this:

在清单文件中更改为:

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

回答by B.?NER

This works for me

这对我有用

getSupportActionBar().hide();

回答by MD.JULHAS HOSSAIN

For Beginner Like Me. Just Do it what I say.From your Android Project.

对于像我这样的初学者。照我说的去做。来自你的 Android 项目。

app -> res -> values -> style.xml

应用程序 -> res -> 值 -> style.xml

replace this code

替换此代码

<resources>

<!-- 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>

</resources>

Enjoy.

享受。

回答by ????? ????????

  1. open styles.xml
  2. insert
  1. 打开styles.xml
  2. 插入
 <style name="no_title" parent="AppTheme">
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowContentOverlay">@null</item>
 </style>
 <style name="no_title" parent="AppTheme">
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowContentOverlay">@null</item>
 </style>

you can change name="---------"

您可以更改名称="---------"

  1. open Androidmaifest.xm

    find android:theme="@style/AppTheme" chang to android:theme="@style/no_title"

  2. click select Theme on menubar (it's green color near MainActivity)

    • click project Theme
    • click no_title (on you right hand Side)
    • click OK
  1. 打开 Androidmaifest.xm

    找到 android:theme="@style/AppTheme" 改为 android:theme="@style/no_title"

  2. 单击菜单栏上的选择主题(MainActivity 附近的绿色)

    • 点击项目主题
    • 点击 no_title(在你的右手边)
    • 单击确定