fle*_*ppe 2 textinput react-native
我在将 a 居中时遇到问题,TextInput同时保持占位符可见。我希望文本从占位符开始(居中)开始。
在 IOS 上它可以工作,但在 android 上它只是部分可见。
IOS 上的结果: IOS 占位符
android 上的结果: Android 占位符
这是我的代码:
render() {
return (
<View style={styles.containerStyle}>
<TextInput
underlineColorAndroid='transparent'
placeholder={"Placeholder "}
placeholderTextColor={"grey"}
maxLength={6}
style={{ fontSize: 30, color: "black",
justifyContent: "center", }}
onChangeText={this.props.onChangeText}
value={this.props.value.toUpperCase()}
/>
</View>
);
}
}
const styles = {
containerStyle: {
flexDirection: 'row',
backgroundColor: "#fff",
borderRadius: 5,
borderWidth: 1,
shadowColor: "#000",
elevation: 2,
marginLeft: 5,
marginRight: 5,
alignItems: 'center',
justifyContent: "center"
}
};
Run Code Online (Sandbox Code Playgroud)
flex:1按您的TextInput风格使用
<View style={styles.containerStyle}>
<TextInput
underlineColorAndroid='transparent'
placeholder={"Placeholder "}
placeholderTextColor={"grey"}
maxLength={6}
style={{ flex:1, fontSize: 30, color: "black",
justifyContent: "center", }}
onChangeText={this.props.onChangeText}
value={this.props.value.toUpperCase()}
/>
</View>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1916 次 |
| 最近记录: |