代码之家  ›  专栏  ›  技术社区  ›  user9054759

justifyContent不起作用,我无法更改屏幕的背景色

  •  1
  • user9054759  · 技术社区  · 7 年前

    enter image description here

    我使用的是native base,在这张图片中,您将看到stackedLabel表单。我试图把它移到屏幕的中央,但它不适用于justifyContent,仍然停留在屏幕的顶部。此外,我试图改变整个屏幕的背景色,这也是不工作。 代码如下:

     <Container>
    
           <Content contentContainerStyle={{
            justifyContent:"center",
            flex:1,
            backgoroundColor: #00A577}}>
    
                  <Form style={styles.form}>
            <Field name="email"
            component={this.renderInput}
                   validate={[email, required]} />
            <Field
              name="password"
              component={this.renderInput}
              validate={[alphaNumeric, minLength8, maxLength15, required]}
    
            />
          </Form>
          <Button
    full
            style={styles.button}
          onPress={() => this.signin()}
          >
            <Text style={{color:"#ffffff"}}>Sign In</Text>
    </Button>
    
    
    
    </Content>
    
              </Container>
    

    如何解决这两个问题?

    2 回复  |  直到 7 年前
        1
  •  0
  •   akhil xavier    7 年前

    代替 flex:1 通过 flexGrow:1 在contentContainerStyle中

    密码

    import React, { Component } from 'react';
    import { Container, Header, Content, Form, Item, Input, Button, Text } from 'native-base';
    export default class App extends Component {
      render() {
        return (
          <Container>
            <Content contentContainerStyle={{ justifyContent: "center", flexGrow: 1, backgroundColor: "#00A577" }}>
              <Form>
                <Input placeholder="e-mail" />
                <Input placeholder="password" />
              </Form>
              <Button full>
                <Text style={{ color: "#ffffff" }}>Sign In</Text>
              </Button>
            </Content>
          </Container >
        );
      }
    }
    
        2
  •  -1
  •   cary    7 年前

    “backgoroundColor”上有一个拼写错误。