【发布时间】:2018-06-20 19:11:04
【问题描述】:
我遇到了一个关于 ScrollView 的问题,它没有占据剩余的全部高度,like so。
带有红色边框的视图应该一直向下,因此当键盘退出时视图向上不够and the 5th item is selected。
这是我的这个组件的代码:
<Container>
<Header navigation={this.props.navigation} title="Header" />
<ScrollView style={{
flexGrow: 1,
borderColor: '#F00',
borderWidth: 1,
}}>
<KeyboardAvoidingView behaviour="padding" keyboardVerticalOffset={50} style={{
flex: 1,
}}>
<InputWithLabel label="1st item" editable={true} onTextChange={this.textChange} />
<InputWithLabel label="2nd item" editable={true} onTextChange={this.textChange} />
<InputWithLabel label="3rd item" editable={true} onTextChange={this.textChange} />
<InputWithLabel label="4th item" editable={true} onTextChange={this.textChange} />
<InputWithLabel label="5th item" editable={true} onTextChange={this.textChange} />
</KeyboardAvoidingView>
</ScrollView>
</Container>
这是我的根组件,我也使用 react-navigation 来显示我的组件:
<Root>
<StatusBar translucent={false} barStyle="light-content" />
<Provider store={store}>
<AppRoot/>
</Provider>
</Root>
我尝试弄乱了 keyboardVerticalOffset 参数,但在我的情况下它似乎没有做任何事情。我还尝试在滚动视图上放置“flex: 1”而不是“flexGrow: 1”,但是this is the result。
我在这里错过了什么?
【问题讨论】:
标签: css react-native flexbox