【问题标题】:Is there any way to remove notification/status bar, but not in onCreate?有什么方法可以删除通知/状态栏,但不能在 onCreate 中?
【发布时间】:2012-01-09 16:54:33
【问题描述】:

据我所知,可以隐藏通知/标题栏,一旦 活动是可见的(有内容),但是......也许我错了?

活动可见后有什么办法可以隐藏吗?

【问题讨论】:

    标签: android android-activity statusbar android-notification-bar


    【解决方案1】:

    您可以定义活动以使用消除通知/标题栏的主题。例如,您可以将此作为属性添加到 AndroidManifest.xml 中的 <activity ... > 标记:

    android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
    

    一旦您致电setContentView(),就无法更改标题的存在。在活动开始后隐藏标题栏的唯一方法是使用修改后的意图重新启动活动。做这样的事情:

    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() 进行适当的调用。

    【讨论】:

    • 我知道,这不是我想要的。我根本不想隐藏它,但在活动运行期间的某个时间点。
    猜你喜欢
    • 1970-01-01
    • 2011-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多