有什么方法可以删除通知/状态栏,但不能在onCreate中删除? [英] Is there any way to remove notification/status bar, but not in onCreate?
问题描述
据我所知,一旦 活动可见(有内容),但是...也许我错了?
As far as I know, it is possible to hide the notification/title bar, once the activity is visible (has content) , But... maybe I'm wrong?
在活动可见后,有什么方法可以隐藏它?
Is there any way to hide it after the activity is visible?
推荐答案
您可以定义活动以使用消除通知/标题栏的主题.例如,您可以将此属性作为属性添加到AndroidManifest.xml中的<activity ... >
标记中:
You can define the activity to use a theme that eliminates the notification/title bar. For instance, you can add this as an attribute to your <activity ... >
tag in AndroidManifest.xml:
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
调用setContentView()
后就无法更改标题的存在.活动开始后隐藏标题栏的唯一方法是使用修改后的意图重新启动活动.做这样的事情:
The presence of a title cannot be changed once you have called setContentView()
. The only way to hide the title bar after your activity has started is to restart the activity with a modified intent. Do something like this:
Intent intent = getIntent();
overridePendingTransition(0, 0);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
intent.putExtra("NoTitle", true);
finish();
overridePendingTransition(0, 0);
startActivity(intent);
然后在onCreate()
中测试意图中是否存在多余的"NoTitle",并在调用setContentView()
之前对requestWindowFeature()
进行适当的调用.
Then in onCreate()
test whether the "NoTitle" extra is present in the intent and make the appropriate call to requestWindowFeature()
before calling setContentView()
.
这篇关于有什么方法可以删除通知/状态栏,但不能在onCreate中删除?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!