【问题标题】:How to add safeArea in React Native for Android如何在 React Native for Android 中添加 safeArea
【发布时间】:2020-06-11 14:57:45
【问题描述】:

我正在开发一个带有 react native 的应用程序并使用我的 android 模拟器对其进行测试。React Native 中的SafeAreaView 组件目前仅适用于 ios 版本 11 或更高版本的 ios 设备。

有人知道解决这个问题的方法吗?

【问题讨论】:

    标签: android react-native


    【解决方案1】:

    IOS 使用 SafeAreaView,Android 使用填充

    import React from 'react';
    import { StyleSheet, Text, View} from 'react-native';
    
    export default function App() {
      return (
        <SafeAreaView style={styles.container}>
          //Rest of your app
        </SafeAreaView>
      );
    }
    
    const styles = StyleSheet.create({
      container: {
        flex: 1,
        backgroundColor: '#A6A9BC',
        paddingTop: Platform.OS === 'android' ? 25 : 0
    },
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-08-11
      • 1970-01-01
      • 2017-05-10
      • 1970-01-01
      • 1970-01-01
      • 2015-07-04
      • 2016-09-09
      相关资源
      最近更新 更多