【问题标题】:How to align item in react native?如何在本机反应中对齐项目?
【发布时间】:2021-01-13 17:46:30
【问题描述】:

我想在中间对齐我的徽标(灰色 K)。我把我的理由内容和我的对齐项目放在 K 的中心,但它不起作用。我的观点可能有问题?

IOS版

<View style={{flex: 1, marginBottom: 50}}>
            <View style={{marginLeft: 10, marginRight: 10}}>
              {this.renderMonDashboardOpenDb()}
            </View>
            <View style={{flex: 1, marginLeft: 10, marginRight: 10, alignItems:'center', justifyContent:'center'}}>
             
              <Text
                style={{
                  fontSize: 30,
                  textAlign: 'center',
                  color: 'white',
                 
                }}>
                Klaaap pour défendre tes couleurs !
              </Text>
              </View>
              
             
              <View style={{flex: 1,  alignItems:'center', justifyContent:'center'}}>
              <TouchableOpacity onPress={() => this.props.navigation.navigate('Decibels')}><Image style={styles.logoVert} source={require('./Kvert.png')} /></TouchableOpacity>
              
           
              </View>
[...]
</View>

【问题讨论】:

    标签: javascript ios react-native


    【解决方案1】:

    可能周围View的宽度不是100%? 要弄清楚您可以将 TouchableOpacity 周围的 View 的颜色设置为红色,现在您可以查看它的宽度是否在整个屏幕上。 如果不是,您只需将宽度设置为 100%,一切都会居中。

    希望这可能会有所帮助! 祝你好运。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-02-02
      • 1970-01-01
      • 2022-01-12
      • 2022-08-23
      • 2019-05-17
      • 1970-01-01
      • 2019-05-13
      • 1970-01-01
      相关资源
      最近更新 更多