假设这是布局:
<View style={styles.container}>
<View style={styles.titleWrapper}>
...
...
</View>
<View style={styles.inputWrapper}>
...
...
</View>
<View style={styles.footer}>
<TouchableOpacity>
<View style={styles.nextBtn}>
<Text style={styles.nextBtnText}>Next</Text>
</View>
</TouchableOpacity>
</View>
</View>
我想用页脚的样式使视图定位在屏幕的底部。我尝试将alignSelf
属性赋予页脚,但它没有在底部定位,而是将其定位到屏幕的右侧。我如何才能使页脚项目坚持到最后?谢谢。
发布于 2019-11-26 07:48:59
考虑屏幕结构
<View style={styles.container}>
<View style={styles.body}> ... </View>
<View style={styles.footer}>...</View>
</View>
您可以使用Flexbox方法干净地使用flex-grow。
const Styles = StyleSheet.create({
container:{
flexDirection: 'column', // inner items will be added vertically
flexGrow: 1, // all the available vertical space will be occupied by it
justifyContent: 'space-between' // will create the gutter between body and footer
},
})
注意事项:在嵌套元素的情况下,您必须确保父容器在使用flexGrow时具有足够的高度。将父级和子级上的backgroundColor设置为调试。
https://stackoverflow.com/questions/38887069
复制相似问题