1 | initial version |
To begin a React Native app that supports portrait orientation on both iOS and Android, use the following steps:
npx react-native init MyApp
.AndroidManifest.xml
file located in android/app/src/main
add the following code under the android:label
tag:android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation"
Info.plist
file located in ios/MyApp
add the following code:<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
App.js
file:import React, { Component } from 'react';
import { StyleSheet, View } from 'react-native';
export default class App extends Component {
render() {
return (
<View style={styles.container}>
{/* Add your components here */}
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'column',
justifyContent: 'flex-start',
alignItems: 'stretch',
backgroundColor: '#F5FCFF',
},
});
This will create a basic layout for your app. You can add your components inside the container
view.