Jump to content

React Native - Starting content under camera

Hi, please forgive me if this is something basic, I'm currently learning React Native but am stuck at this point.

So I know that SafeAreaView cannot be used for Android devices so following a YouTube tutorial I have added this line to the styles:

paddingTop: Platform.OS === 'android' ? StatusBar.currentHeight : 0,

The problem I'm facing is while this works and the content is now under the status bar, the punch hole from the camera is covering it, please see my attached screenshot from the Android emulator.
Is it possible to do this so that the content appears under the camera as well?


image.png.7076386a6eb8b6b54261b855ab5a0a9a.png

Ill add my full code here:

import { 
  StyleSheet,
  Text,
  SafeAreaView,
  StatusBar,
  Platform
} from 'react-native';

export default function App() {
  return (
    <SafeAreaView style={styles.container}>
      <Text style={styles.txt}>Test Text</Text>
    </SafeAreaView>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'flex-start',
    justifyContent: 'center',
    flexDirection: 'row',
    paddingTop: Platform.OS === 'android' ? StatusBar.currentHeight : 0,
  },

});

TIA.

Edited by _Luke_
Removed a duplicate in the code
Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×