如何在React Native (Expo)中创建沉浸式全屏应用?
如何基于Expo实现React Native沉浸式全屏应用
我想开发一款基于Expo的React Native沉浸式全屏应用,但网上搜到的方案全是针对裸React Native项目的,需要修改MainActivity.java文件,完全不适用于Expo项目。
后来我参考Expo的app.json配置规范,在配置里添加了这段代码:
"androidNavigationBar": { "visible": "immersive", }
添加配置前,应用的状态栏和导航栏正常显示;添加并重新编译后,导航栏确实隐藏了,但顶部多出一块黑色区域(我特意改成红色方便观察),这块区域无法被我的<View>组件覆盖,我想要彻底移除它,让应用内容能完全填充到状态栏原来的位置。
以下是我的完整app.json配置:
{ "expo": { "name": "Fullscreen", "slug": "Fullscreen", "version": "1.0.0", "orientation": "portrait", "icon": "./assets/icon.png", "userInterfaceStyle": "light", "splash": { "image": "./assets/splash.png", "resizeMode": "contain", "backgroundColor": "#ffffff" }, "androidStatusBar": { "translucent": true, "backgroundColor": "#ffffff" }, "androidNavigationBar": { "visible": "immersive", "backgroundColor": "#ffffff" }, "assetBundlePatterns": [ "**/*" ], "ios": { "supportsTablet": true }, "android": { "adaptiveIcon": { "foregroundImage": "./assets/adaptive-icon.png", "backgroundColor": "#ffffff" } }, "web": { "favicon": "./assets/favicon.png" } } }
内容的提问来源于stack exchange,提问作者Takla Seth
相关产品推荐
相关产品推荐

