(React native) How to use SafeAreaView for Android notch devices?

前端 未结 9 1840
一生所求
一生所求 2020-12-24 06:45

I\'m actually developing an app with react native and i\'m testing with my one plus 6 and it has a notch. The SafeAreaView is a solution for the iPhone X but for Android, it

9条回答
  •  被撕碎了的回忆
    2020-12-24 07:15

    Well, I had the same problem. I solved this using this lib React Native Status Bar Height, and I recommend because it´s a piece of cake to use.
    And if you are using style-components you can add the getStatusBarHeight() on your styles.js like i=I did on the example below:

    import styled from 'styled-components/native';
    
    import { getStatusBarHeight} from 'react-native-status-bar-height';
    
    export const Background = styled.View`
     flex:1;
     background:#131313;
     margin-top: ${getStatusBarHeight()};
    

    `

提交回复
热议问题