Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Position a React Native Button at the bottom of my screen to work on multiple ios devices

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.

like image 700
youngreactNative Avatar asked Apr 04 '16 20:04

youngreactNative


People also ask

How do you place a button at the bottom of the screen in React Native?

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.

How do you put footer at bottom of page in React Native?

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.


2 Answers

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....

like image 134
parker Avatar answered Sep 19 '22 22:09

parker


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:

enter image description here

like image 20
katwal-Dipak Avatar answered Sep 19 '22 22:09

katwal-Dipak