justifyContent 不起作用,我无法更改屏幕的背景颜色
justifyContent is not working and I can't change background color of the screen
我正在使用本机基础,在这张图片中您将看到 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 个问题?
在 contentContainerStyle
中将 flex:1
替换为 flexGrow:1
代码
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 >
);
}
}
您在 'backgoroundColor' 上打错了字。
我正在使用本机基础,在这张图片中您将看到 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 个问题?
在 contentContainerStyle
中将flex:1
替换为 flexGrow:1
代码
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 >
);
}
}
您在 'backgoroundColor' 上打错了字。