Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native 'Modal' Component Not Covering Entire Screen on Android when using Full Screen Theme

The title says it all. I've edited the styles.xml file (/projectname/android/app/src/res/values/styles.xml) to contain the following:

<resources>
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
        <item name="android:windowFullscreen">true</item>
        <item name="android:windowContentOverlay">@null</item>
    </style>
</resources>

This code successfully makes the app fullscreen, removing the Android status bar. However, if I launch a React Native 'Modal' component the modal only extends as far to the top as where the edge of the status bar would have been, leaving a gap the size of a status bar. How would I modify the modal to extend all the way to the top?

Here's a screenshot of the open modal with the gap:

Open modal with gap

like image 570
Steed-Asprey Avatar asked Aug 24 '16 14:08

Steed-Asprey


People also ask

How do I display modal in react-native full screen?

Adding the prop presentationStyle="pageSheet" does the trick.

How do I stop react-native modal from moving up when keyboard opens Android?

Try giving {position: 'absolute'} in its style props!

How do I customize modal in react-native?

Open screens/TabOneScreen . Change the code to look like the code block below: import * as React from "react"; import { Button, StyleSheet, Text, View } from "react-native"; import Modal from "react-native-modal"; export default function TabOneScreen() { const [isModalVisible, setIsModalVisible] = React.

How do I make react full screen?

You can use a useEffect to request fullscreen on the document body when it first loads.


1 Answers

you can apply statusBarTranslucent={true} to the react native <Modal> component like example below

<Modal statusBarTranslucent={true}>
//your modal content
<Modal />

knowing that, the statusBarTranslucent={true} only available for android

like image 53
Anas Avatar answered Sep 20 '22 18:09

Anas