I am trying to show a media player above the bottom tab navigator just like in spotify app.
It should stay there in same state across all the screens (bottom tabs).
Any suggestions or approaches to implement this in React native ?
You just need to calculate the height of Bottom Navbar and make a View with Position:’absolute’ and to keep it above Bottom Navbar assign the height of Navbar to ‘bottom’ of this View.
I would suggest to use an React.Context as you wanna show the same object (music control panel) on each screen with same state and not an replica on each screen.
For positioning I suggest using an absolute position. This works together with "react-navigation" because header and bottom areas are changed.
This means bottom:0 is no longer the screens bottom within a tab navigator it’s right above the TabBar.
4
Answers
You just need to calculate the height of Bottom Navbar and make a View with Position:’absolute’ and to keep it above Bottom Navbar assign the height of Navbar to ‘bottom’ of this View.
I would suggest to use an React.Context as you wanna show the same object (music control panel) on each screen with same state and not an replica on each screen.
For positioning I suggest using an
absolute
position. This works together with "react-navigation" because header and bottom areas are changed.This means
bottom:0
is no longer the screens bottom within a tab navigator it’s right above the TabBar.Here is an example:
I just solved this problem
2023 Solution – How to show an element or component above the "bottom Tab Navigator" in React Native?
Create a Fragment and place your component "FooterRadioPlayer" UNDER the Tab.Navigator’s
Then in your component stylesheet, align it to your desire.
Final Result
Hopefully this gives a different solution…