删除应用标题栏android
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23255373/
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
Remove app title bar android
提问by sparrkli
I know this question has been asked million times but whichever method I use is not good for me.
我知道这个问题已被问过数百万次,但无论我使用哪种方法都不适合我。
If I use
如果我使用
android:theme="@android:style/Theme.NoTitleBar"
in the manifest file, the whole theme of the app changes. If I put
在清单文件中,应用程序的整个主题发生了变化。如果我把
requestWindowFeature(Window.FEATURE_NO_TITLE);
in the onCreate activities, it shows up shortly when starting an app.
在 onCreate 活动中,它会在启动应用程序时立即显示。
Btw I don't have any theme selected, just using standard android.
顺便说一句,我没有选择任何主题,只是使用标准的 android。
回答by CommonsWare
It is unclear what you mean by "whole theme of app changes". For API Level 11+ devices, you probably should be using @android:style/Theme.Holo.NoActionBar
.
目前尚不清楚“应用程序更改的整个主题”是什么意思。对于 API 级别 11+ 的设备,您可能应该使用@android:style/Theme.Holo.NoActionBar
.
回答by Aswin Rajendiran
If you add the theme to the application, it applies to the whole app.
如果您将主题添加到应用程序,它将适用于整个应用程序。
android:theme="@android:style/Theme.NoTitleBar"
You have to add it to the activity declaration.
您必须将其添加到活动声明中。
<activity
android:name=".YourActivity"
android:theme="@android:style/Theme.NoTitleBar"/>
回答by user3541496
To remove the title bar from your app in android studio
在 android studio 中从您的应用程序中删除标题栏
- Open res > values > styles.xmlfile
Replace your code with:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
- 打开res > values > styles.xml文件
将您的代码替换为:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
回答by user3821354
Open your style.xml file, create a new style just like below. You choose your own name and set the parent as below
打开你的 style.xml 文件,像下面一样创建一个新的样式。您选择自己的名字并设置父级如下
<style name="your_own_name" parent="Theme.AppCompat.Light.NoActionBar">
</style>
In your AndroidManifest.xml file, set the theme name for the specific activity you dont want the bar to show and you are done
在您的 AndroidManifest.xml 文件中,为您不希望栏显示的特定活动设置主题名称,您就完成了
<activity android:theme ="@style/your_own_name" >
</activity>
回答by Bhanz
This is what worked for me
这对我有用
android:theme="@style/Theme.AppCompat.NoActionBar">
回答by Fawaz
For android 8 and above support. Use this in your app theme file. I've modified my default in res/styles.xml :
对于 android 8 及更高版本的支持。在您的应用主题文件中使用它。我在 res/styles.xml 中修改了我的默认值:
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:background">@color/white</item>
</style>
回答by MohdTausif
when you create a new project in android then you will get default theme applied on your project, that has title bar. but if you want to remove or apply some other theme for your whole App then you can define like below at application level:
当您在 android 中创建一个新项目时,您将在项目上应用默认主题,该主题具有标题栏。但是如果你想为你的整个应用程序删除或应用一些其他主题,那么你可以在应用程序级别定义如下:
<application
android:name="com.mycomp.myproj.MainApplication"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Sherlock" >
but if you want to apply some theme only at some specific screens then you can define like below at activity level:
但是如果您只想在某些特定屏幕上应用某些主题,那么您可以在活动级别定义如下:
<activity
android:name="com.mycomp.myproj.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme">
回答by Sam
Inside AndroidManifest
在 AndroidManifest 中
<activity
android:name=".activity.HomeMenu"
android:screenOrientation="nosensor"
android:theme="@android:style/Theme.Light.NoTitleBar">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
and make sure your Class extends to Activity
并确保您的类扩展到 Activity
回答by Aaron Thompson
If you have made a custom theme in styles.xml you can do this:
如果您在styles.xml 中创建了自定义主题,您可以这样做:
<style name="AppTheme" parent="android:Theme.Material.Light">
<!-- Override the android colour scheme etc. -->
<item name="android:colorPrimary">@color/color_primary</item>
</style>
To remove the Action bar and title add to styles.xml:
删除操作栏和标题添加到styles.xml:
<style name="AppTheme.NoActionBar">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
Then in your AndroidManifest.xml you can use your custom theme with or without the action bar
然后在您的 AndroidManifest.xml 中,您可以使用带有或不带有操作栏的自定义主题
<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"> <---- With action bar
<activity
android:theme="@style/AppTheme.NoActionBar"> <---- No action bar
<intent-filter>
etc...