[英]How to hide android system' s bottom navigation bar in React Native App without changing MainActivity? Maybe through AndroidManifest?
我想隱藏系統的底部導航欄。 我使用了“ 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。
/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找不到。
錯誤:鏈接引用失敗。
失敗:構建失敗,發生異常。
com.android.ide.common.process.ProcessException:無法執行aapt
由於我的應用程序具有需要全屏模式的視頻屏幕,因此請通過提供一種方法將其永久隱藏在react-native或建議其他npm package()或幫助我解決發布版本錯誤,來幫助我。
謝謝
隱藏導航欄
您可以使用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);
}
關於我的答案的此鏈接
或使用此鏈接
import FullScreen from 'react-native-full-screen'
FullScreen.onFullScreen()
FullScreen.offFullScreen()
以書面形式引用另一個答案的文章。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.