2

I have 2 button places in a row like this:

enter image description here

I want to remove the space between the two buttons and have them side by side in a row like this:

enter image description here

How can I achieve this?

My Code:

<View
  style={{
    flexDirection: "row",
    alignItems: "stretch",
    justifyContent: "center",
    marginTop: 10
  }}
>
  <View style={{ flex: 1 }}>
    <Button title="Button 1" />
  </View>
  <View style={{ flex: 1 }}>
    <Button title="Button 2" />
  </View>
</View>

I am using import { Button } from "react-native-elements";

3iL
  • 2,146
  • 2
  • 23
  • 47

3 Answers3

1

There is default CSS of Button(react-native-elements) already applied to it like padding and margin. you have to override that css with your one and then apply flex and flexDirection to attach both Buttons.

Try this code

<View style={{flex: 1, flexDirection: 'row'}}>
   <Button style={{marginRight: 0}} title="Button 1" />
   <Button style={{marginLeft: 0}} title="Button 2" />
</View>
Ankit Dubey
  • 243
  • 3
  • 11
0

Use flexDirection to attach two.

<View style={{ flex: 1, flexDirection: "row" }}>
    <Button title="Button 1" />
    <Button title="Button 2" />
  </View>
hong developer
  • 13,291
  • 4
  • 38
  • 68
0
<View style={{flex:1}}>
<View style={{ flexDirection: "row"}}>
<View style={{flexGrow: 1, flexBasis: 1}}>
<Button title="one" />
</View>
<View style={{flexGrow: 1, flexBasis: 1}}>
<Button title="two" />
</View>
</View>
Tejaswi katha
  • 29
  • 1
  • 17