Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set windowSoftInputMode programmatically on different screens in react-native?

Tags:

react-native

In my react-native app, I need different screen behaviour on different screens when keyboard pops up.
In some screens i need the screen to move up, and in some screens i do not want to change the screen position etc.

Individual behaviours can be achieved by setting values of android:windowSoftInputMode to adjustNothing or adjustResize in AndroidManifest.xml file.

But setting these values in the manifest file changes the behaviour for all the screens.

Is there a way to change it programmatically within different screens ?

In android code it looks achievable using a getWindow() call. How to do it in react-native ?

like image 345
kernelman Avatar asked Oct 24 '25 05:10

kernelman


2 Answers

Try this component react-native-android-keyboard-adjust

When the component in which you don't want to move up views mounts, set AndroidKeyboardAdjust.setAdjustPan() and when that component unmount reset it to AndroidKeyboardAdjust.setAdjustResize() or whatever option that suits your criteria

See this answer

like image 155
Ayesha Saeed Avatar answered Oct 26 '25 21:10

Ayesha Saeed


try use ScrollView instead of View then wrap it on KeyboardAvoidingView

like image 39
Praya Avatar answered Oct 26 '25 23:10

Praya



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!