【问题标题】:Display inline-block equivalent in react native在本机反应中显示等效的内联块
【发布时间】:2020-03-11 22:29:30
【问题描述】:

我需要做到这一点:

https://jsfiddle.net/ghxfpL7j/1/

在 React Native 中但是:

  • 文本中不能有视图
  • 您不能为文本设置边距或内边距

我尝试在视图和文本中使用“C”,然后在另一个视图中使用带有数字的其他文本,但我无法实现相同的效果,因为名称太长时不起作用。

这是我尝试过的:

<View style={a}>
  <View style={b}><Text style={c}>C</Text></View>
  <Text style={d}>Player name</Text>
  <View style={e}>20</View>
</View>

然后是样式:

a: {
  flexDirection: 'row',
  flexWrap: 'wrap'
}

b:{
  width: 20,
  backgroundColor: '#000'
}

c:{
  color: '#ddd
}

d:{
  flex: 1,
  text-align: 'right'
}

e:{
  text-align: 'right'
}

【问题讨论】:

标签: css react-native


【解决方案1】:

根据您的链接,可能是:

<View style={{ flexDirection: 'row' }}>
    <View style={{ flex: 1 }}>
        <Text>C</Text>
    </View>

    <Text>Player Name</Text>
    <Text>25</Text>
</View>

【讨论】:

    猜你喜欢
    • 2021-05-30
    • 2016-03-12
    • 1970-01-01
    • 1970-01-01
    • 2021-09-24
    • 2021-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多