[英]How to hide android system' s bottom navigation bar in React Native App without changing MainActivity? Maybe through AndroidManifest?
I want to hide the system's bottom navigation bar. 我想隐藏系统的底部导航栏。 I used "react-native-navigation-bar-color" but it causes a build error, strangely while release build only.
我使用了“ react-native-navigation-bar-color”,但它会导致生成错误,奇怪的是仅在发布版本中。
I thought I could remove this package(react-native-navigation-bar-color) and permanently hide the navbar by changing MainActivity but the MainActivity in React Native does not inherit AppCompatActivity in order for it to have "onCreate" method in which I can write the code(as per android studio documentation) to hide. 我以为我可以删除此包(react-native-navigation-bar-color)并通过更改MainActivity永久隐藏导航栏,但是React Native中的MainActivity不会继承AppCompatActivity以便它具有“ onCreate”方法,我可以在其中编写代码(根据android studio文档)隐藏。
Following is the build error: /Users/yashjaveri/.gradle/caches/transforms-1/files-1.1/appcompat-v7-28.0.0.aar/f688ce916ebedb5188b6c1f4470868ef/res/values-v28/values-v28.xml:9:5-12:13: AAPT: error: resource android:attr/dialogCornerR adius not found. 以下是构建错误:/Users/yashjaveri/.gradle/caches/transforms-1/files-1.1/appcompat-v7-28.0.0.aar/f688ce916ebedb5188b6c1f4470868ef/res/values-v28/values-v28.xml:9: 5-12:13:AAPT:错误:找不到资源android:attr / dialogCornerR adius。
/Users/yashjaveri/Documents/React/ReactNative_Projects/SLink/node_modules/react-native-navigation-bar-color/android/build/intermediates/res/merged/release/values-v28/values-v28.xml:11: AAPT: error: resource android:attr/dialogCornerRadius not found. /Users/yashjaveri/Documents/React/ReactNative_Projects/SLink/node_modules/react-native-navigation-bar-color/android/build/intermediates/res/merged/release/values-v28/values-v28.xml:11:AAPT :错误:找不到资源android:attr / dialogCornerRadius。
/Users/yashjaveri/.gradle/caches/transforms-1/files-1.1/appcompat-v7-28.0.0.aar/f688ce916ebedb5188b6c1f4470868ef/res/values/values.xml:1304:5-69: AAPT: error: resource android:attr/fontVariationSettings not found. /Users/yashjaveri/.gradle/caches/transforms-1/files-1.1/appcompat-v7-28.0.0.aar/f688ce916ebedb5188b6c1f4470868ef/res/values/values.xml:1304:5-69:AAPT:错误:资源android :attr / fontVariationSettings找不到。
/Users/yashjaveri/.gradle/caches/transforms-1/files-1.1/appcompat-v7-28.0.0.aar/f688ce916ebedb5188b6c1f4470868ef/res/values/values.xml:1304:5-69: AAPT: error: resource android:attr/ttcIndex not found. /Users/yashjaveri/.gradle/caches/transforms-1/files-1.1/appcompat-v7-28.0.0.aar/f688ce916ebedb5188b6c1f4470868ef/res/values/values.xml:1304:5-69:AAPT:错误:资源android :attr / ttcIndex找不到。
error: failed linking references. 错误:链接引用失败。
FAILURE: Build failed with an exception. 失败:构建失败,发生异常。
com.android.ide.common.process.ProcessException: Failed to execute aapt
com.android.ide.common.process.ProcessException:无法执行aapt
Please help me out either by providing way to hide navbar permanently in react-native or by suggesting any other npm package() or by helping me solve the release build error, as my app has a video screen which requires full screen mode. 由于我的应用程序具有需要全屏模式的视频屏幕,因此请通过提供一种方法将其永久隐藏在react-native或建议其他npm package()或帮助我解决发布版本错误,来帮助我。
Thank you 谢谢
Hide the Navigation Bar 隐藏导航栏
You can hide the navigation bar using the SYSTEM_UI_FLAG_HIDE_NAVIGATION flag. 您可以使用SYSTEM_UI_FLAG_HIDE_NAVIGATION标志隐藏导航栏。 This snippet hides both the navigation bar and the status bar:
此代码段同时隐藏了导航栏和状态栏:
ote the following: 请注意以下几点:
@Reactmethod
public void hidenavigationbar() {
View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
}
this link about my answer 关于我的答案的此链接
import FullScreen from 'react-native-full-screen'
FullScreen.onFullScreen()
FullScreen.offFullScreen()
an article referenced in writing another answer . 以书面形式引用另一个答案的文章。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.