无法删除活动中的标题栏 [英] can not remove title bar in Activity
问题描述
我想删除活动顶部的标题。我尝试了这两种方法,但在api级别8中却没有。
i want to remove title on top of my Activity. i tried this two way they work but not in api level 8.
1:
<style name="NOtitleTheme" parent="Theme.AppCompat.Light">
<item name="android:windowFullscreen">true</item>
<item name="android:windowNoTitle">true</item> </style>
2:
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
不知道为什么在 api 8 $ c $上不起作用c>?
一旦我设法在 api 8
中将其删除,但我不记得如何。
once i managed to remove it in api 8
, but i do not remember how.
编辑:
已解决!问题是 this.requestWindowFeature(Window.FEATURE_NO_TITLE)
在API 8上不起作用,并且<项目名称= android:windowNoTitle> true< / item>
不起作用,但是 actionBar.hide()
可以工作,这是getSupportActionBar( )返回null在使用两个选项之一之前,我只是忘了同时删除两者。当我删除一个我添加其他(一个愚蠢的!)
谢谢大家! (对不起,英语不好)
Solved! the problem was this.requestWindowFeature(Window.FEATURE_NO_TITLE)
does not work on API 8, and also <item name="android:windowNoTitle">true</item>
does not work, but actionBar.hide()
works , the reason that getSupportActionBar() returns null was using one of the two option before, i just forget to remove both. when i remove one i add other(what a a stupid !)
thanks all! (sorry for bad English)
推荐答案
添加到清单中:
进行全屏显示:
<activity
android:name="youtpackagename.activityname"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
或(仅隐藏标题)
<activity
android:name="youtpackagename.activityname"
android:theme="@android:style/Theme.NoTitleBar" >
或在 setContentView
方法之前使用以下代码
or else use below code before setContentView
method .
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
或
{
ActionBar actionBar = getActionBar(); or getSupportActionBar();
actionBar.hide();
}
编辑:
final ActionBar actionBar = getActionBar();
actionBar.setDisplayShowTitleEnabled(false);
在api 8以下也能正常工作。希望对您有所帮助
Its working fine below api 8 also.. i hope this will help you
这篇关于无法删除活动中的标题栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!