React native 键盘AvoidingView-向上推送内容

React native 键盘AvoidingView-向上推送内容,react-native,React Native,我尝试使用KeyboardAvoidingView(也尝试了一些替代方法),但它要么在输入字段上显示键盘,要么在键盘和输入字段之间添加大量填充。当我在页面上添加任何其他内容的条带时,效果会更好,只在输入字段和键盘之间添加了一点填充 本期演示: {this.state.story.image_key? :null } {this.state.story.title} 通过{this.state.story.author.name}导航('User',{id:this.state.story.a

我尝试使用KeyboardAvoidingView(也尝试了一些替代方法),但它要么在输入字段上显示键盘,要么在键盘和输入字段之间添加大量填充。当我在页面上添加任何其他内容的条带时,效果会更好,只在输入字段和键盘之间添加了一点填充

本期演示:


{this.state.story.image_key?
:null
}
{this.state.story.title}
通过{this.state.story.author.name}导航('User',{id:this.state.story.author.id,name:this.state.story.author.name})}>第1章
{this.state.story.content}
{this.state.story.chapters.map(函数(第1章){
返回导航('User',{id:chapter.author.id,name:chapter.author.name})}>
})}
写组件

import React from 'react';
import {
    AppRegistry,
    TextInput
} from 'react-native';

export default class WritingComponent extends React.Component {

    constructor(props) {
        super(props);
        this.state = { text: '' };
    }

    render() {
        return (
            <TextInput
                style={{height: 40, borderColor: 'gray', borderWidth: 1}}
                multiline={true}
                onChangeText={(text) => this.setState({text})}
                value={this.state.text}
            />
        )
    }
}

AppRegistry.registerComponent('WritingComponent', () => WritingComponent);
从“React”导入React;
进口{
评估学,
文本输入框
}从“反应本机”;
导出默认类WritingComponent扩展React.Component{
建造师(道具){
超级(道具);
this.state={text:'};
}
render(){
返回(
this.setState({text})}
值={this.state.text}
/>
)
}
}
AppRegistry.registerComponent('WritingComponent',()=>WritingComponent);

我认为问题在于滚动视图,
应该包含在
键盘AVOIDGVIEW
中,因为您希望在键盘打开时也调整此滚动容器的大小…

将keyboardVerticalOffset=“80”与KeyboardAVOIDGVIEW一起设置。 根据部件的宽度增加/减少80

import React from 'react';
import {
    AppRegistry,
    TextInput
} from 'react-native';

export default class WritingComponent extends React.Component {

    constructor(props) {
        super(props);
        this.state = { text: '' };
    }

    render() {
        return (
            <TextInput
                style={{height: 40, borderColor: 'gray', borderWidth: 1}}
                multiline={true}
                onChangeText={(text) => this.setState({text})}
                value={this.state.text}
            />
        )
    }
}

AppRegistry.registerComponent('WritingComponent', () => WritingComponent);