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.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-05-06 13:10:49 +0000
Seen: 13 times
Last updated: May 06 '23
What could be the reason for the node app not functioning on Namecheap hosting?
How does rate limiting work for Azure Function in .NET 7?
How to identify the screen location of the mouse pointer in an electron app?
What is missing since the androidmanifest.xml file is not present?
When attempting to launch my Android app, why does my AVD open YouTube instead?
How can I set up a subdomain for Apple app site association?