我正在尝试更改应用程序的背景颜色,但该颜色无法填充整个屏幕。当我将flex设置为0时,背景色仅覆盖所需的数量,但是当我将其设置为1时,它不会缩小整个屏幕,而是会缩小。我做错了什么?
下面是代码,更改了根视图的flex: render(){ 返回(
<Text>{welcome}</Text>
<TextInput
underlineColorAndroid="rgba(0,0,0,0)"
placeholder={email}
autoCapitalize="none"
style={styles.textInput}
onChangeText={email1 => this.setState({ email1 })}
/>
<TextInput
underlineColorAndroid="rgba(0,0,0,0)"
secureTextEntry
placeholder={password}
autoCapitalize="none"
style={styles.textInput}
onChangeText={password1 => this.setState({ password1 })}
value={this.state.password1}
/>
{this.state.errorMessage && (
<Text style={styles.error}>{this.state.errorMessage}</Text>
)}
<TouchableOpacity
onPress={this.handleSignUp}
style={styles.buttonContainer}
>
<Text style={styles.buttonText}>{signup}</Text>
</TouchableOpacity>
<Text
style={styles.text}
onPress={() => this.props.navigation.navigate("LoginScreen")}
>
{already_have_an_account}
</Text>
</KeyboardAvoidingView>
);
} }
const styles = StyleSheet.create({
container: {
justifyContent: "center",
padding: 20,
backgroundColor: "red",
flex: 0
},
textInput: {
height: 40,
marginTop: 8,
paddingHorizontal: 8,
backgroundColor: "#e2e2e2"
},
buttonContainer: {
backgroundColor: "#3bd774",
padding: 15,
marginTop: 10
},
buttonText: {
textAlign: "center",
color: "white",
fontWeight: "bold"
},
logo: {
width: 200,
height: 200
},
logoContainer: {
alignItems: "center",
justifyContent: "center"
},
text: {
marginTop: 16,
color: "#bcbcbc",
textAlign: "center"
},
error: {
marginTop: 8,
color: "red"
}
});
答案 0 :(得分:0)
答案 1 :(得分:0)
您需要确保在视图链中一直具有flex:1。这是因为flex:1将使视图填充其父视图
我可以看到您复制/粘贴的内容不是全部代码,因为有import tensorflow as tf
with tf.variable_scope("model"):
y = 1
with tf.variable_scope("model2"):
z = 1
但没有开始标签。
因此,至少您需要一个</KeyboardAvoidingView>
,但是如果有包装的内容,则还应在该控件中添加flex:1。