连续删除2个按钮之间的空间

时间:2019-04-23 13:29:42

标签: react-native react-native-elements react-native-button

我连续有2个按钮位置,如下所示: 我想删除两个按钮之间的空间,并排成一行,如下所示: 我该如何实现? 我的代码: <查看   样式= {{     flexDirection:“行”,     alignItems:“拉伸”,     justifyContent:“中心”,     marginTop:10   }} >   <查看样式= {{flex:1}}>     

3 个答案:

答案 0 :(得分:1)

已经应用了Button(react-native-elements)的默认CSS,例如padding和margin。您必须使用您的CSS覆盖该CSS,然后应用flex和flexDirection来附加两个按钮。

尝试此代码

<View style={{flex: 1, flexDirection: 'row'}}>
   <Button style={{marginRight: 0}} title="Button 1" />
   <Button style={{marginLeft: 0}} title="Button 2" />
</View>

答案 1 :(得分:0)

使用flexDirection附加两个。

<View style={{ flex: 1, flexDirection: "row" }}>
    <Button title="Button 1" />
    <Button title="Button 2" />
  </View>

答案 2 :(得分: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>