![](/img/trans.png)
[英]How to hide action bar on HTC one using Holo.NoActionBar theme
[英]How can I hide app's name in Android when using a theme with no action bar?
app_name 出於某種原因出現在左上角。 為什么? 看這里:
我的應用程序全屏運行並隱藏 UI 元素,例如操作欄。 應用程序中僅有的兩個組件是約束視圖和顯示“voluble”一詞的中心 textView。
我能想到的唯一原因可能是應用程序的父主題,即 Theme.MaterialComponents.DayNight.NoActionBar。 但是我仍然無法找到如何防止這種情況發生或首先為什么會發生這種情況。
我想到了。
我使用這個函數來隱藏 UI 元素:
public void fullScreenCall() {
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
}
我打電話給:
@Override
protected void onResume() {
super.onResume();
fullScreenCall();
}
出於某種原因,將此添加到 fullScreenCall 函數的 uiOptions 可修復它:
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
最終工作代碼:
public void fullScreenCall() {
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.