2017-02-07 49 views

回答

5

我最終添加了一個marginTop與設備的狀態欄的值。

import { 
    StatusBar, 
} from 'react-native' 

在我的全局樣式表:

header: { 
    marginTop: StatusBar.currentHeight, 
} 
0

我發現了一個更好的辦法這個使用StyleProvider我的主題,然後進入脫組件的文件夾(本機基本主題/組件)來處理髮現Header.js文件並更改paddintTop值(大約305行)

10

由於此問題僅在Android中出現,因此推薦的解決方法是使用專門針對Android的平臺

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

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

     } 
}) 

容器是應用程序中的主容器。

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

到目前爲止我找到的最佳答案! – Silex