React Native:文本和图标内联

React Native: Text and Icon inline

我正在尝试内联一个图标和一个文本,并将文本左对齐,图标右对齐...

这是它现在的样子:

但是,我希望文本左对齐,图标右对齐,并且两者高度相同...

到目前为止我的代码:

<Text
  style={{
    fontSize: 16,
    paddingTop: 15,
    paddingBottom: 15,
    paddingLeft: 10,
    paddingRight: 10,
    color: "black"
  }}
>
  Kategorien:
  <Icon
    style={{
      alignItems: "center",
      justifyContent: "center",
      textAlign: "right"
    }}
    name="keyboard-arrow-down"
    type="MaterialIcons"
  />
</Text>

我也尝试过使用 react native 元素并使用左右元素,但是,在这种情况下,图标和文本不是内联的...

<View>
  <Left>
    Text...
  </Left>
  <Right>
    Icon...
  </Right>
</View>

你们有什么想法吗?

您需要使用查看文本和图标组件进行包装。你可以在那里设置水平和垂直填充。

       <View style={{
            paddingVertical: 15,
            paddingHorizontal: 10,
            flexDirection: "row",
            justifyContent: "space-between",
            alignItems: "center"
        }}>
            <Text style={{
                    fontSize: 16,
                    color: "black"
                }}>Kategorien:</Text>
            <Icon/>
        </View>