0

我希望将视图工具栏与页面底部对齐,而不使用 justifyContent 属性的“空格”。

查看底部需要对齐的工具栏

下面是我如何制作这个工具栏的代码:

    <View style={{ height: '100%', justifyContent: 'space-between', }}>

    <View style={{ flexDirection: 'row', height: 44,
     alignItems: 'center', justifyContent: 'space-around', 
     backgroundColor: 'yellow'}}>

       <Image source={require('./resources/images/grid.png')}/>
        <Image source={require('./resources/images/grid.png')}/>
        <Image source={require('./resources/images/grid.png')}/>
        <Image source={require('./resources/images/grid.png')}/>
        <Image source={require('./resources/images/grid.png')}/>

    </View>
    </View>
4

1 回答 1

0

我查看了底部和位置属性。当我将底部:0,位置:'绝对'添加到内部视图样式时,我们还需要指定宽度。(不知道为什么相对允许自动取全宽)。但是如果我们添加 { bottom: 0, position: 'absolute', width: '100%') 那么内部视图将始终在底部对齐。像下面

<View style={{ flexDirection: 'row', height: 44,
 alignItems: 'center', justifyContent: 'space-around', 
 backgroundColor: 'yellow', bottom: 0, position: 'absolute', width: '100%'}}>

   <Image source={require('./resources/images/grid.png')}/>
    <Image source={require('./resources/images/grid.png')}/>
    <Image source={require('./resources/images/grid.png')}/>
    <Image source={require('./resources/images/grid.png')}/>
    <Image source={require('./resources/images/grid.png')}/>

</View>
</View>
于 2018-12-10T07:27:17.327 回答