【问题标题】:Android and React Native top navigation BarAndroid 和 React Native 顶部导航栏
【发布时间】:2019-01-04 12:40:43
【问题描述】:

我想问你关于下面图片中选择的部分。

这部分的名称是什么,我如何在 React Native 中设置它的样式?现在我的 APK 有一个难看的白条,我看不到电池电量或 WiFi。

【问题讨论】:

    标签: android react-native uinavigationbar react-navigation


    【解决方案1】:

    有电池和时间的区域称为status bar。在我见过的大多数情况下,状态栏的高度取决于 ReactNative 的 Platform 模块中的平台。

    之后,您可以将此高度传递给 <View> 并添加其他样式。

    import { Platform, ... } from 'react-native'
    
    ...code...
    
    const STATUS_BAR_HEIGHT = Platform.select({ ios: 20, android: 24 })
    
    export default class MyComponent extends Component {
    
      ...code...
    
      render() {
        <View style={{ height: STATUS_BAR_HEIGHT, ...more styles here... }} />
        <View>
    
          ...code...
    
        </View>
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-17
      • 1970-01-01
      • 1970-01-01
      • 2019-11-03
      • 1970-01-01
      • 2021-01-31
      • 1970-01-01
      • 2020-02-15
      相关资源
      最近更新 更多