gpt4 book ai didi

react-native - 如何在 React Native 中将 TextInput 放在屏幕底部?

转载 作者:行者123 更新时间:2023-12-04 00:34:27 29 4
gpt4 key购买 nike

我制作了一个聊天应用程序,我想将 TextInput 放在页面底部,但我无法做到。如果我尝试 position: 'absolute' + bottom: 0 显示为空。我想我的风格有弹性问题,我不确定。

这是我的 MessageScreen 代码:

render() {
return (
<Wallpaper>
<KeyboardAvoidingView behavior='padding'>
<View>
<TextInput
style={styles.input}
onChangeText={text => this.setState({ message: text })}
// value={this.state.email}
placeholderTextColor='white'
underlineColorAndroid='transparent'
/>
<Button onPress={this.send} title='SEND' />
</View>
</KeyboardAvoidingView>
</Wallpaper>
);
}
}

const styles = StyleSheet.create({
text: {
color: 'white',
fontWeight: 'bold',
backgroundColor: 'transparent',
paddingLeft: 25
},
input: {
backgroundColor: 'rgba(255, 255, 255, 0.4)',
width: DEVICE_WIDTH ,
height: 40,
color: '#ffffff'
},
image: {
width: 40,
height: 40
}
});

这是壁纸:
render() {
return (
<Image style={styles.picture} source={require('src/components/images/wallpaper.png')}>
{this.props.children}
</Image>
);
}
}

const styles = StyleSheet.create({
picture: {
flex: 1,
width: undefined,
height: undefined,
resizeMode: 'cover'
}
});

最佳答案

尝试这个。

<View style={styles.container}>
<KeyboardAvoidingView
style={{position: 'absolute', left: 0, right: 0, bottom: 0}}
behavior="position"
>
<TextInput
style={styles.input}
onChangeText={text => this.setState({ message: text })}
// value={this.state.email}
placeholderTextColor='white'
underlineColorAndroid='transparent'
/>
<Button onPress={this.send} title='SEND' />
</KeyboardAvoidingView>
</View>

可以找到工作示例 here

关于react-native - 如何在 React Native 中将 TextInput 放在屏幕底部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45876884/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com