簡體   English   中英

如何保留操作/標題欄但隱藏通知欄

[英]How can I keep the action/title bar but hide the notification bar

如何保留操作/標題欄但隱藏通知欄?

這個問題看起來已經得到了回答,但我找到的大部分答案都隱藏了操作欄和通知欄。 我希望能夠保留動作/標題欄。 我得到的最好的是隱藏它們並使用線性布局來顯示自定義動作/標題欄但我想要一個系統生成的。 還可以在顯示通知欄時隱藏操作欄嗎?

要隱藏通知欄,請使用以下代碼:

WindowManager.LayoutParams attrs = act.getWindow().getAttributes();
attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
act.getWindow().setAttributes(attrs);

要顯示通知欄,請使用以下代碼:

WindowManager.LayoutParams attrs = act.getWindow().getAttributes();
attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
act.getWindow().setAttributes(attrs);

你可能想調用Activity.onCreate()中的代碼。

<style name="MyCustom_Theme.FullScreen">
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>
</style>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM