有什么方法可以将图像放在屏幕左侧,并以React Native上的文本为中心?

问题描述 投票:0回答:1

[伙计们,我对React Native有疑问。我希望顶部的多维数据集图像位于显示“ OLL 1”的文本旁边,而底部的多维数据集则位于显示“ OLL 2”的文本旁边。我的观点如下:

<View style={styles.images}>
  <Image source={require('./rubiks-cube.png')} style={styles.image}></Image>
  <Image source={require('./OLL.jpg')} style={styles.image}></Image>
</View>
<View style={styles.algorithms}>
  <Text style={styles.algorithmstext}>OLL 1</Text>
  <Text style={styles.algorithmstext}>OLL 2</Text>
</View>

我的样式表如下:

algorithms: {
  flex: 1,
  flexDirection: 'column',
},
algorithmstext: {
  fontSize: 40,
  padding: 20,
},
images: {
  flex: 1,
  flexDirection: 'column',
  alignItems: 'flex-end',
  position: 'absolute',
},
image: {
  height: 100,
  width: 100,
},

但是该应用看起来像这样。有什么方法可以将图像放在屏幕左侧?我需要保持绝对位置,以便图像不会向下推文本,但是如果我将位置:“绝对”放置在“图像”样式上,则图像会彼此重叠,您只能看到图像之一。有谁知道我该如何解决?

App Screenshot

javascript reactjs react-native
1个回答
0
投票

尝试以下样式

images: {
    flex: 1,
    flexDirection: 'column',
    alignItems: 'flex-end',
//    position: 'absolute', <-- Remove this
  },
© www.soinside.com 2019 - 2024. All rights reserved.