【问题标题】:React Native button not align centerReact Native 按钮未对齐中心
【发布时间】:2020-04-10 06:03:22
【问题描述】:

我在我的原生基本表单中包含了一个按钮,但它没有居中对齐。

<Form>
   ...

   <Item inlineLabel>
      <View style={styles.alignCenter}>
         <Button primary style={styles.btnUpd}><Text> Update </Text></Button>
      </View>
   </Item>
</Form>

我的风格:

const styles = StyleSheet.create({
  alignCenter: {
    flexDirection: 'row',
    justifyContent: 'center',
    alignItems: 'center'
  },
  btnUpd: {
    height: 35,
    marginTop: 4,
    marginBottom: 4,
  }
});

我以为我只需要使用 justifyContent 和 alignItems center 来集中对象。我错过了什么?

谢谢

【问题讨论】:

    标签: react-native native-base


    【解决方案1】:

    使用&lt;Body&gt; 标签将其设置为屏幕中心,对于屏幕的左侧和右侧,您可以像这样使用&lt;Left&gt;&lt;Right&gt;

    <View>
       <Body>
          <Button>
             <Text> Update </Text>
          </Button>
       </Body>
    </View>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-23
      • 1970-01-01
      • 1970-01-01
      • 2014-07-19
      • 2020-09-18
      • 2019-03-14
      • 2019-07-04
      • 2015-08-24
      相关资源
      最近更新 更多