作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 tabnavigator 中有组件。在我的组件中,我有多行文本,所以当我在 InputText 键盘上输入多行时,我想使用 KeyboardAvoidingView 在键盘显示时推送屏幕。
这是我的代码:
class UselessTextInput extends Component {
render() {
return (
<TextInput
{...this.props} // Inherit any props passed to it; e.g., multiline, numberOfLines below
editable={true}
autoFocus={false}
placeholder={Const.TEXT_INPUT_DELETE_ACCOUNT}
//maxLength={10000}
underlineColorAndroid='rgba(0,0,0,0)'
placeholderTextColor={'gray'}
/>
);
}
}
class SettingProfileDetail extends React.Component {
render(){
return (
<KeyboardAvoidingView behavior="padding" style={styles.container}>
<Text style={styles.textTitle}>
{Const.REASONDELETEACCOUNT}
</Text>
<UselessTextInput
style={styles.textInput}
multiline={true}
numberOfLines={1}
onChangeText={(text) => this.setState({ reason: text })}
value={this.state.reason}
/>
</KeyboardAvoidingView >
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'column',
backgroundColor: 'white',
},
textTitle: {
fontFamily: font.bold,
textAlign: 'center',
color: '#666666',
marginTop: 20,
marginBottom: 18
},
textInput: {
fontFamily: font.normal,
marginLeft: 10,
marginRight: 10,
padding: 0
},
});
最佳答案
我遇到了同样的问题,尽管我有一种不同的方法,它基本上会在键盘出现时计算和定位(使用 translateY) View 。
我已经在这里发布了,请访问 react-native-spacer更多默认
关于react-native - KeyboardAvoidingView 不适用于 TabNavigator,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49363932/
我是一名优秀的程序员,十分优秀!