gpt4 book ai didi

android - 导航回屏幕时,隐藏的 React Native 状态栏不起作用 (Android)

转载 作者:行者123 更新时间:2023-11-29 23:56:25 46 4
gpt4 key购买 nike

我用过<StatusBar hidden />我也试过 StatusBar.setHidden(true)在 componentWillMount() 和 render() 方法中,它在我第一次打开组件时起作用。但是,如果我导航到另一个屏幕,然后再次打开上一个屏幕,大多数情况下会出现状态栏。

有没有办法保证状态栏在每个组件中始终隐藏?

提前致谢

编辑:

主 Activity .java

package com.wixnav2;

import com.reactnativenavigation.controllers.SplashActivity;

import android.content.Intent;
import android.content.res.Configuration;

public class MainActivity extends SplashActivity {

@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
Intent intent = new Intent("onConfigurationChanged");
intent.putExtra("newConfig", newConfig);
this.sendBroadcast(intent);
}

@Override
public void onCreate(Bundle savedInstanceState) {
Window window = getWindow();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(ContextCompat.getColor(this, R.color.transparent));
}
}
}

最佳答案

您可以在 Activity 类的 onCreate 中使用此代码

 if (Build.VERSION.SDK_INT >= 21) {

requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);

}

如果使用 SplashActivy 你可以使用这段代码

Window window = getWindow();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(ContextCompat.getColor(this, R.color.transparent));
}

关于android - 导航回屏幕时,隐藏的 React Native 状态栏不起作用 (Android),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50327756/

46 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com