【发布时间】:2019-01-24 20:51:08
【问题描述】:
我正在尝试使用 react native 创建一个 Messenger,但我遇到了一个似乎无法解决的问题。这是到目前为止的样子,我在输入旁边有一个发送按钮(来自 React Native Elements 的按钮组件),它与按钮的视图相同,如下所示:
这里的按钮被正确放置在输入旁边。然而,每当输入和视图因输入多行而增长时,按钮就会随之向上移动:
当输入只有一行时,如何始终将按钮保持在相同的位置?
这是我的代码:
<KeyboardAvoidingView style={styles.container}
behavior="padding"
keyboardVerticalOffset={64}>
<View>
<FlatList
//...
/>
<View
minHeight={45}
style={{flexDirection:'row', backgroundColor: 'transparent' }}>
<TextInput
style={[styles.textInput, {fontSize:17,marginVertical: 0, width:300, marginLeft: 10}]}
minHeight={25}
multiline={true}
enablesReturnKeyAutomatically={true}
keyboardAppearance="dark"
placeholder=""
onChangeText={(message) => {this.setState({message})}}
value={this.state.message}
/>
<Button
buttonStyle={{borderRadius: 25, bottom:-5, marginLeft: 10, paddingVertical: 5, backgroundColor: "#EAB844"}}
icon={{name: 'arrow-up', type: 'feather', color:'white'}}
onPress={()=>{ this.onPressButton()}}
title=""/>
</View>
</View>
</KeyboardAvoidingView>
【问题讨论】: