View.SYSTEM_UI_FLAG_FULLSCREEN不适用于HUAWEI P20

问题描述 投票:0回答:1

我有并且发出活动/片段必须以全屏模式进入的位置(如果用户展开视图)。这实际上适用于(几乎)所有设备,使用以下代码:

 decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);

但是,不知何故,HUAWEI P20并非如此。它隐藏了状态栏,但是有一个空格,底部内容与底部导航重叠。在其他设备上,它显示正确(全屏,没有空格)。我尽可能地尝试使用android:fitsSystemWindows="true",但没有什么能解决这个问题。

编辑:我实际上也隐藏了工具栏,但该部分在所有设备(包括华为P20)上按预期工作。唯一的问题是华为P20的状态栏。

有什么建议?

照片:

enter image description here

android fullscreen statusbar huawei
1个回答
0
投票

可能你忘了添加两条额外的线条。

ActionBar actionBar = getActionBar();
actionBar.hide();

您可以使用manifest.xml,为目标活动添加主题。

<application
    ...
    android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen" >
    ...
</application>

或者,您可以以编程方式设置。

if (Build.VERSION.SDK_INT < 16) {
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }
else
{
View decorView = getWindow().getDecorView();
// Hide the status bar.
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
// Remember that you should never show the action bar if the
// status bar is hidden, so hide that too if necessary.
ActionBar actionBar = getActionBar();
actionBar.hide();
}

有关更多信息,请阅读android documentation

© www.soinside.com 2019 - 2024. All rights reserved.