我用的是NativeBase和Exponent.标题位于手机的状态栏下方.你可以在Exponent发布的NativeBase演示中看到这一点.

enter image description here

有人能解决这个问题吗?

推荐答案

由于这个问题只在安卓系统中出现,建议解决这个问题的方法是专门针对安卓系统使用Platform:

import {Platform, StatusBar} from 'react-native'

const styles = StyleSheet.create({
    container: {
            flex: 1,
            ...Platform.select({
                android: {
                    marginTop: StatusBar.currentHeight
                }
            })

        }
})

其中container是应用程序中的主容器.

<View style={styles.container}>
 // rest of the code here
</View>

React-native相关问答推荐

如何在Recact Native中单击Back按钮后调用函数

React Native - 如何在从另一个屏幕导航后将 ScrollView 滚动到给定位置

React Native 的 Firebase 初始错误(无法读取未定义的属性getItem)

在 React Native Paper 中更改 TextInput 的文本 colored颜色

react Navigation 在标题中使用图像?

如何将抖动动画添加到视图(react-native)?

如何在 React Native For Android 中删除启动画面后的白屏

使用 create-react-native-app 创建了一个应用程序,如何将其发布到 Google Play store ?

如何判断 goBack() 函数在react-navigation 中是否可行?

有没有办法改变 IOS 标题上react-navigation 的默认后退按钮 colored颜色 ?

我可以在 react-native 中使用 reactJS 库吗?

null 不是对象(判断 this.state.count)

有react-native复选框的例子吗?

如何将本地文本文件加载到 React Native Project 中的字符串变量中?

React-Native:更改 ImageBackground 的不透明度 colored颜色

在 OPTIONS 响应后使 fetch API 与 CORS 一起工作

试图在一个本应是不可变且已被冻结的对象上设置密钥

React Navigation 切换背景 colored颜色 和样式 StackNavigator

React Native 中的 CSS 三角形

如何更改后退按钮标签,react-navigation