Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

mobile - React native align bottom does not align to bottom

I am trying to make a mapp app with a box on the bottom with info in it. I am trying to also align the text to the bottom also the container of it. It aligns the container but not the text. but sometimes it displays correctly.

Img of what it displays

My code is:

import React, { Component } from 'react';
import { StyleSheet, Text, View, Button } from 'react-native';

const Rectangle = (props) => {
    return <View style={styles.rectangle}>
        <Text style={styles.nameText}>
            Deak Ter
        </Text>
        <Text style={styles.descText} onPress = {props.updateState}>
        {props.myState}
        </Text>
        <Text style={styles.btn}>
            GO
        </Text>
    </View>;
    
  };
  
  const styles = StyleSheet.create({
    rectangle: {
        backgroundColor: 'rgb(220, 220, 220)',
        width: 100 * 2.5,
        height: 100 * 3.5,
        borderRadius: 30,
        paddingTop: 25,
        paddingLeft: 25,
        alignSelf: 'flex-end',
        position: 'absolute', //Here is the trick
        bottom: 0, //Here is the trick
    },
    nameText: {
        fontSize: 30,
        paddingTop: 5,

    },
    descText: {
        paddingTop: 5,

        fontSize: 22
    },
    btn: {        
        backgroundColor: 'rgb(0, 234, 255)',
        width: 100,
        height: 60,
        fontSize: 35,
        textAlign: 'center',
        textAlignVertical: 'center',
        position: 'absolute', //Here is the trick
        bottom: 70,
        left: 20
    }

  });

  export default Rectangle;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...