I am young to react native search the web for tutorials that could help me with this problem but have not find anything. I know how to move the buttons from point A to B on my screen. The thing is I just cant seem to get it to be fixed at the bottom to work on different form factors of my ios emulator. So far I have tried marginTop which takes down the button to the screen but as soon as a I change the emulator to a different screen size the button goes up a little. I am asking can I get any guidance as how I may set this to work on different ios screens.
submitButton: {
height: 85,
flex: 1,
backgroundColor: "#FFBB34",
borderColor: "#555555",
borderWidth: 0,
borderRadius: 0,
marginTop: 200,
justifyContent: "flex-start"
}
The code above is my button.
Position button at the bottom The solution is to use add a container for the button, and use flex-end inside so that the button moves to the bottom. The flex tells the bottom view to take the remaining space. And inside this space, the bottom is laid out from the bottom, that's what the flex-end means.
to set the outer View to have the flex style set to 1 to make it fill the screen. Then we add a ScrollView that fills the height of the outer View except for the height of the footer View . Now we should see 'footer' stays at the bottom.
You can use absolute position to put things wherever you want...
submitButton: { position: 'absolute', bottom:0, left:0, }
will put at bottom of screen, left side....
Here is how I placed the floating button at the bottom-right of the screen.
return (
<View style={mainConatinerStyle}>
{this.renderSwiper()}
{this.renderFloatingMenu()}
</View>
);
Use the following styles for container & button:
mainConatinerStyle: {
flexDirection: 'column',
flex: 1
},floatingMenuButtonStyle: {
alignSelf: 'flex-end',
position: 'absolute',
bottom: 35
}
Output:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With