I want to have all children filling the available space, and overlapping one another, so only the last child is visible.
<View style={???}>
<View style={???} /> // Not visible (if bg color set on next child)
<View style={???} />
</View>
I've tried various combinations of flex, position, alignSelf: stretch, etc., and can't find a winning combo.
I think you want something like this:
component/index.js:
component/style.js:
So,
Viewwithrootstyle will fill all space of its parent since it hasflex: 1. And it hasposition: relative, so the children with absolute positioning will act accordingly.Views withchild1andchild2both have absolute positioning (StyleSheet.absoluteFillObjectis a shortcut for{position: 'absolute', top: 0, right: 0, bottom: 0, left: 0}docs here).child1andchild2will overlap andchild2will be on top ofchild1since it is rendered later.