Not able to fill the whole height of DrawerContentScrollView

5.5k Views Asked by At

I am developing the nagivation drawer:

<Drawer.Navigator
    initialRouteName={InitialScreen}
    drawerContent={props => <MyDrawer {...props} />}
    screenOptions={{
        headerShown: true,
    }}>
    <Drawer.Screen name="main" component={MainScreen} />
</Drawer.Navigator>

As you can see above, I am customizing the content of the drawer by implementing my own MyDrawer component.

In the rendering part of MyDrawer, I have:

return (
    <View style={styles.myContent}>
      <DrawerContentScrollView
        style={{flex: 1, top: 0, bottom: 0, backgroundColor: 'yellow'}}
        {...props}>
        <View
          style={{
            backgroundColor: 'green',
            flex: 1,
            width: '100%',
            height: '100%',
          }}>
          <View>
            <DrawerItem name="Purhcase" text="Purchase" />
            <DrawerItem name="Sell" text="Sell" />
          </View>
          ...
        </View>
      </DrawerContentScrollView>
    </View>
  );

const styles = StyleSheet.create({
  myContent: {
    flex: 1,
    paddingLeft: 0,
    paddingTop: 10,
  }
});

I would like to have that green color View component which wrapped directly by DrawerContentScrollView filling the whole height of the DrawerContentScrollView. The above code shows what I tried, but no matter what I do, that green color View component always only occupy the height according to what content that it wraps. How to make it fill the whole height then?

1

There are 1 best solutions below

6
On BEST ANSWER

Change the style prop on your DrawerContentScrollView to contentContainerStyle.