Chalanika Sewwandi
Chalanika Sewwandi

Reputation: 33

How to add safeArea in React Native for Android

I'm developing an app with react native and testing it with my android emulator.The SafeAreaView component in React Native is currently applicable only to ios devices with ios version 11 or later.

Did someone know about anything to solve this issue?

Upvotes: 1

Views: 2745

Answers (1)

Randula Wickramasuriya
Randula Wickramasuriya

Reputation: 111

Use SafeAreaView for IOS and use a padding for 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
},
});

Upvotes: 2

Related Questions