如何在android中禁用状态栏而不隐藏它?

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

我想永久禁用状态栏,而不是隐藏它。 我可以通过在 system.prop 中给出

qemu.hw.mainkeys=1
并构建图像来禁用导航栏。 但是,我没有找到任何禁用状态栏的方法。  我什至尝试使用以下标志 -

View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
View.SYSTEM_UI_FLAG_FULLSCREEN;

但是,这些会暂时隐藏状态栏和导航栏。如果用户点击屏幕,它们就会弹出。有了这些标志,它们就不会被完全禁用。网上有很多关于如何隐藏状态栏和导航栏的解决方案,但没有完全禁用它们。

1) 我发现禁用状态栏和导航栏的唯一方法是禁用 systemui。

pm disable com.android.systemui

但我注意到,禁用 systemui 会禁用很多东西,例如 SD 卡、音量、壁纸等。

2)我尝试的另一种方法是将

status_bar_height
中的
frameworks/base/core/res/res/values/dimens.xml
更改为
0dp
,如下所示-

    <!-- Height of the status bar -->
    <dimen name="status_bar_height">@dimen/status_bar_height_portrait</dimen>
    <!-- Height of the status bar in portrait -->
    <dimen name="status_bar_height_portrait">0dp</dimen>
    <!-- Height of the status bar in landscape -->
    <dimen name="status_bar_height_landscape">@dimen/status_bar_height_portrait</dimen>

但是,这导致启动动画无法加载,进而无法显示屏幕内容(我的 lvds 变黑了)。

如何禁用状态栏? 

android android-layout android-source android-statusbar
1个回答
0
投票

我能够隐藏状态栏的唯一方法是使用此命令

settings put secure user_setup_complete 0

您可以通过将其设置为 1 来再次启用它或使用以下命令获取当前状态

settings get secure user_setup_complete

另一个想法可能是使用您现在使用的内容来隐藏它,但编辑状态栏java类源代码中的滑动事件函数不执行任何操作,因此向下滑动会被忽略。

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