如何解决选中时 React Native TextInput 会缩小,我该如何停止它?
我是 React Native 的新手,我目前正在开发一个应用程序,在登录屏幕上,当我选择电子邮件或密码字段时,键盘出现并且整个屏幕都在缩小,我该如何防止?
这里是渲染函数和样式:
render() {
return (
<View style={styles.container}>
<View style={styles.image} >
<LoginBubble />
</View>
<Text style={styles.appName}>App Name</Text>
<Text style={styles.lipsum} >Lorem ipsum dolor sit amet,consectetur adipiscing elit.</Text>
<View style={styles.input}>
<View style={styles.icon}>
<EmailIcon />
</View>
<TextInput
style={styles.emailInput}
placeholder="Email"
onChangeText={(text) => this.setState({ email: text })}
onSubmitEditing={Keyboard.dismiss}
autoCapitalize="none"
placeholderTextColor="#29374E"
/>
</View>
<View style={styles.input}>
<View style={styles.icon}>
<PasswordIcon />
</View>
<TextInput
style={styles.passwordInput}
placeholder="Password"
secureTextEntry={true}
onChangeText={(text) => this.setState({ password: text })}
onSubmitEditing={Keyboard.dismiss}
autoCapitalize="none"
placeholderTextColor="#29374E"
/>
</View>
<TouchableOpacity
style={styles.loginButton}
>
<Text style={styles.loginButtonText} >Login</Text>
</TouchableOpacity>
<TouchableOpacity>
<Text style={styles.help}>Need help?</Text>
</TouchableOpacity>
</View>
);
}
}
const styles = StyleSheet.create(
{
container:
{
justifyContent: "center",flex: 1,backgroundColor: "white",marginTop: getStatusBarHeight()
},image:
{
justifyContent: "center",alignItems: "center",marginTop: "-5%"
},appName:
{
fontSize: 36,color: "#29374E",alignSelf: "center",fontWeight: "700",marginTop: "2%",//fontFamily: "Inter-SemiBoldItalic"
},lipsum:
{
color: "#AABCD0",width: "60%",marginBottom: "7%",textAlign: "center"
},input:
{
borderColor: "#DEE8F3",borderWidth: 1,marginTop: 10,fontSize: 16,borderRadius: 32,height: "8%",marginHorizontal: 16,//fontFamily: "Arboria-Book",flexDirection: "row",justifyContent: "flex-start",},icon:
{
padding: 16
},emailInput:
{
//marginLeft: "5%",width: "86%",passwordInput:
{
marginLeft: "1%",fontSize: 16
},loginButton:
{
backgroundColor: "#2276D8",borderRadius: 41,justifyContent: "center",marginHorizontal: 16
},loginButtonText:
{
fontSize: 18,color: "white",help:
{
fontSize: 16,color: "#2276D8",alignSelf: 'center',marginTop: "10%"
}
}
);
export default LoginScreen;
解决方法
看看这个:
它有一些解决方案
,在 android\app\src\main\AndroidManifest.xml 中
chnage -> android:windowSoftInputMode="adjustResize" 到 "adjustPan"
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。