如何禁用/删除android活动标签和标签栏?
您可以通过在AndroidManifest.xml中设置的android:theme
属性@android:style/Theme.NoTitleBar
您<activity>
元素上这样实现这一点:
<activity android:name=".Activity"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
我不是100%肯定这是你想要的,但如果你指的是标题栏(顶部的小灰条),您可以删除/通过您的manifest.xml文件自定义...
<activity android:name=".activities.Main"
android:theme="@android:style/Theme.NoTitleBar">
每当我做耙运行:机器人,
我Androidmenifest.xml文件被建成再这样我的变化做
为NoTitlebar没有更多的坚持。
而不是用户adroid_title:0
这对我有帮助。
编辑您的build.yml
android: android_title: 0 #rest of things #you needed
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//set up notitle
requestWindowFeature(Window.FEATURE_NO_TITLE);
//set up full screen
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
还有一个下拉菜单在Eclipse的图形布局窗口。这个菜单中的一些主题最后会有“.NoTitleBar”。其中任何一种都会有窍门。
这一个。
android:theme="@style/android:Theme.NoTitleBar"
不适用于appcompat。 – busuu 2017-07-21 12:31:20
如果您的应用程序的主题是AppTheme(或其他任何东西),然后在styles.xml中添加以下代码:
<style name="HiddenTitleTheme" parent="AppTheme">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
然后在清单文件中添加行动标签下面为您要禁用活动标签:
android:theme="@style/HiddenTitleTheme"
这对我来说很合适,因为在其他情况下,“@ android:style/Theme.NoTitleBar”我得到了这个错误“你需要在这个活动中使用Theme.AppCompat主题(或者后代)。”谢谢 – 2018-02-19 03:20:49
对我来说,别人的答案是不够的......
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
</application>
测试在Android 4.0.3 API 15
你可以使用这个在在AndroidManifest.xml你的活动代码隐藏标签
android:label=""
与你的工具栏,你可以解决这个问题。使用setTitle方法。
Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);
mToolbar.setTitle("");
setSupportActionBar(mToolbar);
超级容易:)
有两种方式通过隐藏它在一个特定的活动或在您的应用程序隐藏它的所有活动,以隐藏标题栏。
您可以通过在您的styles.xml
中创建自定义主题来实现此目的。
<resources>
<style name="MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
如果您正在使用AppCompatActivity,有一堆Android提供时下的主题。如果你选择的主题有.NoActionBar
或.NoTitleBar
。它会禁用你的主题的行动栏。
设置自定义主题后,您可能需要在活动/活动中使用主题。转到清单并选择要设置主题的活动。
比活度
AndroidManifest.xml中
<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name">
<activity android:name=".FirstActivity"
android:label="@string/app_name"
android:theme="@style/MyTheme">
</activity>
</application>
注意,我已经设置了FirstActivity
主题定制主题MyTheme
。这样主题只会受到某些活动的影响。如果您不想为所有活动隐藏工具栏,请尝试使用此方法。
第二种方法是将主题设置为所有活动的位置。我已经设置了应用主题的自定义主题MyTheme的
所有活动
<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/MyTheme">
<activity android:name=".FirstActivity"
android:label="@string/app_name">
</activity>
</application>
通知。这样主题只会受到所有活动的影响。如果您想隐藏所有活动的工具栏,请尝试使用此方法。
如果您使用过Android Studio 3+这将工作:机器人:主题= “@风格/ Theme.AppCompat.NoActionBar”
@android:风格/ Theme.NoTitleBar不会在新的API和力量支持你的应用关闭。
是的,它是我想要的。非常感谢。 – Faren 2010-12-24 15:37:36
如果你想删除标题栏和应用标签,但继续使用主题(如`Theme.Holo.Light`),请查看[本答案](http://*.com/a/10318745/1438809)。 – Felix 2013-07-06 02:46:26
在我的情况下,我认为这是因为appcompat和新的API级别是:`android:theme =“@ style/Theme.AppCompat.NoActionBar”` – Lyoneel 2015-07-20 03:41:47