在 React Native 中将 View 置于其他 View 之上

Place View on top of other View in React Native

我想要的是在多个其他视图之上显示一条线(或一个视图)。

我已经尝试使用 position: absolutez-index 并在代码中将我想要的内容写在最后。不幸的是,其中 none 个可以解决问题。我怎样才能把线放在最上面?

这是我得到的:

这是代码:

<ScrollView style={styles.container}>

  <View style={styles.items}>
    {this.state.items.map((item, index) =>
      <View style={styles.item} key={index} elevation={3} />
    }
  </View>

  <View style={styles.line} />

</ScrollView>
const styles = StyleSheet.create({
  container: {
    flex: 1
  },
  row: {
    margin: 10
  },
  line: {
    backgroundColor: 'blue',
    position: 'absolute',
    top: 0,
    bottom: 0,
    left: 80,
    width: 7,
  }

您是否尝试过将其他组件的 z-index 设置为 0,并将该行的索引设置为 1?你也可以尝试使用position:fixed 属性。希望这有帮助

好的,所以我找到了问题 xD

显然 elevation={3} 搞砸了。如果我简单地从 Views 行中删除这个道具,一切都会正常。