我想隐藏系统的底部导航栏。我使用了“react-native-navigation-bar-color”但是它会导致构建错误,奇怪的是只发布版本。
我想我可以删除这个包(react-native-navigation-bar-color)并通过更改MainActivity永久隐藏导航栏,但React Native中的MainActivity不继承AppCompatActivity,以便它具有“onCreate”方法,我可以在其中编写代码(根据android studio文档)隐藏。
以下是构建错误:/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 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:错误:资源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:错误:资源android :找不到attr / ttcIndex。
错误:链接引用失败。
FAILURE:构建因异常而失败。
请帮助我提供方法来永久隐藏导航栏中的反应原生或建议任何其他npm包()或帮助我解决发布版本错误,因为我的应用程序有一个需要全屏模式的视频屏幕。
谢谢
隐藏导航栏
您可以使用SYSTEM_UI_FLAG_HIDE_NAVIGATION标志隐藏导航栏。此代码段隐藏了导航栏和状态栏:
注意以下几点:
@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关于我的回答
或者使用这个link
import FullScreen from 'react-native-full-screen'
FullScreen.onFullScreen()
FullScreen.offFullScreen()
写作another answer的文章。