[英]Need to hide and disable status bar in react native using android native code
我正在嘗試使用 android 本機代碼在本機反應中禁用狀態欄和主頁和歷史按鈕。 React native 為 back btn 提供 function ,所以這樣做了。
package com.kiosk;
import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
import org.devio.rn.splashscreen.SplashScreen;
import android.os.Bundle;
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript. This is used to schedule
* rendering of the component.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
SplashScreen.show(this);
FullScreencall();
super.onCreate(savedInstanceState);
}
public void FullScreencall() {
if(Build.VERSION.SDK_INT < 19){
View v = this.getWindow().getDecorView();
v.setSystemUiVisibility(View.GONE);
} else {
//for higher api versions.
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
decorView.setSystemUiVisibility(uiOptions);
}
}
@Override
protected String getMainComponentName() {
return "AwesomeProject";
}
@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegate(this, getMainComponentName()) {
@Override
protected ReactRootView createRootView() {
return new RNGestureHandlerEnabledRootView(MainActivity.this);
}
};
}
}
error: cannot find symbol
v.setSystemUiVisibility(View.GONE);
^
symbol: variable View
location: class MainActivity
error: cannot find symbol
View decorView = getWindow().getDecorView();
^
symbol: class View
location: class MainActivity
error: cannot find symbol
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
^
symbol: variable View
location: class MainActivity
error: cannot find symbol
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
^
symbol: variable View
location: class MainActivity
您是否曾經在 react native 或 java 中這樣做過,請幫幫我,我卡住了,一些代碼片段會有所幫助
您忘記導入視圖 class。 將此行添加到 MainActivity.java 的開頭:
import android.view.View;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.