Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
990 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 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...