0
I’m developing a messaging app in React-Native. When clicking on the text input, and the IOS keyboard is displayed, it hides the text input view, which is displayed at the bottom of the screen. How do I get this view to move, staying visible, above the keyboard??
I’ve tried Keyboardavoidingview, but it didn’t work and ruined the layout.
The same is happening in the Android Emulator.
export default class Conversa extends Component {
render() {
return (
<ImageBackground style={styles.principalBg} source={require('../imgs/bg.png')}>
<View style={styles.conversa}>
<Text>Conversa</Text>
</View>
<View style={styles.box}>
<View style={styles.ajuste}>
<TextInput placeholder="Mensagem"
placeholderTextColor={'#000000'} style={styles.input}
onChangeText={ () => false }
/>
</View>
<View>
<TouchableOpacity>
<Image source={require('../imgs/btn-enviar.png')} />
</TouchableOpacity>
</View>
</View>
</ImageBackground>
);
}
}
const styles = StyleSheet.create({
principalBg: {
flex: 1,
},
conversa: {
flex: 1,
padding: 10,
paddingBottom: 20,
},
box: {
position: 'absolute',
bottom: 0,
left: 0,
flexDirection: 'row',
height: 80,
padding: 10,
alignContent: 'center',
backgroundColor: '#115e54',
justifyContent: 'space-between',
borderTopColor: '#FFF',
borderTopWidth: 1,
},
ajuste: {
width: '85%',
},
input: {
fontSize: 18,
height: 60,
backgroundColor: '#FFF',
borderRadius: 5,
paddingLeft: 10,
}
});
I’ll test it again by putting inside the Keybordavoidingview just this part you mentioned. I had done putting everything that was inside the render() and it didn’t work, it disfigured everything. Then put the result.
– renanq
In this way, it is possible to notice that the view moves upwards, but it does not move enough to be visible above the keyboard. You know what I can change to make her move around more???
– renanq
In IOS I managed to adjust using the property "keyboardVerticalOffset" of the component Keyboardavoidingview. Then I will test on Android. thanks!
– renanq
If the answer solved your problem, mark it as correct
– sant0will