繁体   English   中英

使用没有操作栏的主题时,如何在 Android 中隐藏应用程序的名称?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM