Joelend
Joelend

Reputation: 185

How do I set up Scroll within an absolute parent View?

I have a parent div with absolute position and a ScrowView inside.

<View style={styles.containerDados}>

        <ScrollView style={styles.containerRolagem}>

          <View style={styles.containerPropagandas}><Text style={styles.titleText}>Propagandas</Text></View>

          <View style={styles.containerTitle}><Text style={styles.titleText}>Barbearias</Text></View>
          <View style={styles.containerFiltros}><Text>Filtros</Text></View>
          <View style={styles.containerBarbearias}>

          </View>
        </ScrollView>
      </View>

containerDados:{
    flex:1,
    position:'absolute',
    left:0,
    right:0,
    top:0,
    backgroundColor:colors.primary
  },
  containerRolagem:{

    zIndex:5,
    width:'100%',
    height:'100%',
    backgroundColor:'red',
    paddingHorizontal:15
  },

If I take the absolute from the parent Scrow works, otherwise it won't.

I need the father to be absolute, how can I do?

Upvotes: 1

Views: 222

Answers (1)

bmovement
bmovement

Reputation: 867

I think the parent needs to have a height or a bottom set in order to be absolutely positioned. I think the flex: 1 is ignored when position is absolute. Which makes the parent have a height of zero.

Upvotes: 1

Related Questions