Javascript 如何在React Native中的多个子父视图中垂直居中一个子视图

Javascript 如何在React Native中的多个子父视图中垂直居中一个子视图,javascript,ios,react-native,Javascript,Ios,React Native,我有一个视图a(视图-图像),它是B(文本)和C(文本)的父视图。我希望B文本始终在A中垂直和水平居中。在容器A上使用alignItems:“center”,justifyContent:“center”的问题是,它考虑B和C的组合高度,然后根据组合高度垂直居中。我只希望B在A的中心,C在底部对齐 B必须始终垂直居中对齐,无论其高度或B包含的文本长度如何 C必须始终与容器A的底部对齐 以下是我试图获得的视觉效果: 以一些代码为例: <View style={styles.viewA}

我有一个视图a(视图-图像),它是B(文本)和C(文本)的父视图。我希望B文本始终在A中垂直和水平居中。在容器A上使用
alignItems:“center”
justifyContent:“center”
的问题是,它考虑B和C的组合高度,然后根据组合高度垂直居中。我只希望B在A的中心,C在底部对齐

  • B必须始终垂直居中对齐,无论其高度或B包含的文本长度如何
  • C必须始终与容器A的底部对齐
以下是我试图获得的视觉效果:

以一些代码为例:

<View style={styles.viewA}>
    <Text style={styles.textB}>
      I should be vertically centered in A, regardles of my size or the size / place of C.
    </Text>
    <Text style={styles.TextC}>
      I should be on the bottom of A
    </Text>
</View>

const styles = StyleSheet.create({
  viewA: {
    height: 360,
    width: 360,
    alignItems: 'center', // doesn't work
    justifyContent: 'center', // doesn't work
    ???: ???
  },
  viewB: {
    ???
  },
  viewC: {
    ???
  }
});

我应该垂直居中于A,我的尺寸或C的尺寸/位置。
我应该站在一条船的底部
const styles=StyleSheet.create({
视图A:{
身高:360,
宽度:360,
alignItems:'居中',//不起作用
justifyContent:'中心',//不起作用
???: ???
},
视图B:{
???
},
viewC:{
???
}
});
您应该使用来对齐项目。以下是方法:

<View style={styles.viewA}>
  <View style={styles.textB}>
     <Text>
    I should be vertically centered in A, regardles of my size or the size / place of C.</Text>
  </View>
  <View style={styles.TextC}>
    <Text>
      I should be on the bottom of A
    </Text>
 </View>
</View>

const styles = StyleSheet.create({
 viewA: {
  height: 360,
  width: 360,
  alignItems: 'center', // doesn't work
  justifyContent: 'center', // doesn't work
  flex: 1
 },
 viewB: {
  flex: .8
 },
 viewC: {
  flex: .2
 }
});

我应该垂直居中于A,我的尺寸或C的尺寸/位置。
我应该站在一条船的底部
const styles=StyleSheet.create({
视图A:{
身高:360,
宽度:360,
alignItems:'居中',//不起作用
justifyContent:'中心',//不起作用
弹性:1
},
视图B:{
弹性体:.8
},
viewC:{
弹性体:.2
}
});