Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/202.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 安卓立即隐藏状态栏_Java_Android_Kotlin_Android Actionbar_Statusbar - Fatal编程技术网

Java 安卓立即隐藏状态栏

Java 安卓立即隐藏状态栏,java,android,kotlin,android-actionbar,statusbar,Java,Android,Kotlin,Android Actionbar,Statusbar,我正试图隐藏状态栏。这是我的代码: window?.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN actionBar?.hide() 状态栏是隐藏的,但行为不是预期的。 假设我有两项活动。活动A和活动B。活动A有一个绿色状态栏,活动B需要隐藏状态栏。在活动B中,在执行setContentView()之前,我调用代码以隐藏onCreate()中条形图的状态。因此,当切换到“活动B”时,绿色状态栏将在前几秒钟显示,

我正试图隐藏状态栏。这是我的代码:

 window?.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN
 actionBar?.hide()
状态栏是隐藏的,但行为不是预期的。
假设我有两项活动。活动A和活动B。活动A有一个绿色状态栏,活动B需要隐藏状态栏。在活动B中,在执行setContentView()之前,我调用代码以隐藏onCreate()中条形图的状态。因此,当切换到“活动B”时,绿色状态栏将在前几秒钟显示,并且仅在其隐藏后显示。我需要在转换到活动B后立即隐藏状态栏。

在活动B中,您只需在MaterialToolbaror或CollingToolBarLayout中设置
android:FitsystemWindows=“true”

在Java文件中使用此方法OnCreate方法
requestWindowFeature(窗口功能\u无\u标题);this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_全屏,WindowManager.LayoutParams.FLAG_全屏)

谢谢您的回答,但在我的活动B中只有androidx.appcompat.widget.Toolbar
materialtoolbor
Toolbar
是相同的。您可以试试。状态栏仍会显示几秒钟。非常欢迎您