Source:  Twitter logo

What I want is to display a line (or a View) on top of multiple other Views.

I have tried with position: absolute, z-index and to write the thing I want on top last in the code. Unfortunately none of these does the trick. How can I get the line on top?

This is what I get:

This is the code:

<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,
  }

Ok so I found the problem xD

Apparently the elevation={3} messes it up. Everything works if I simply remove this prop from the row Views.

2 users liked answer #0dislike answer #02
howtopythonpls profile pic
howtopythonpls

Have you tried giving the other components a z-index of 0 and the line an index of 1? Also you can try to use a position:fixed property. Hope this helps

0 users liked answer #1dislike answer #10
G.Rose profile pic
G.Rose

Copyright © 2022 QueryThreads

All content on Query Threads is licensed under the Creative Commons Attribution-ShareAlike 3.0 license (CC BY-SA 3.0).