Make an item stick to the bottom using flex in react-native

前端 未结 13 2364
别跟我提以往
别跟我提以往 2020-12-13 23:37

Suppose this is the layout:


    
        ...
        ...
    
             


        
13条回答
  •  臣服心动
    2020-12-14 00:15

    To do this you can use the Stylesheet element position: 'absolute'.

    /*This is an Example to Align a View at the Bottom of Screen in React Native */
    import React, { Component } from 'react';
    import { StyleSheet, View, Text } from 'react-native';
    export default class App extends Component {
      render() {
        return (
          
             Main Content Here
            
              Bottom View
            
          
        );
      }
    }
    const styles = StyleSheet.create({
      containerMain: {
        flex: 1,
        alignItems: 'center',
        justifyContent: 'center',
      },
      bottomView: {
        width: '100%',
        height: 50,
        backgroundColor: '#EE5407',
        justifyContent: 'center',
        alignItems: 'center',
        position: 'absolute', //Here is the trick
        bottom: 0, //Here is the trick
      },
      textStyle: {
        color: '#fff',
        fontSize: 18,
      },
    });
    

提交回复
热议问题