Search code examples
react-nativeviewwindowsubview

add a view to window in react native


I'm developing a react native app primarily for android. I am trying to add a sticky view to the window of the phone, as in iOS, where I can easily access the Window and add a subview to it. But I am struggling with how to do it with react-native.


Solution

  • You can achieve that by using position: 'absolute' and zIndex.

    Wrap the whole app with a single view and add to it style={{position: absolute}}

    See an example here:

    <View style={{flex: 1}}>
      <View style={{position: 'absolute', zIndex: 999}}>...</>
      <SomeView/>
    </View>