Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scrollview can't scroll when focus textinput react native

I have a TextInput inside a ScrollView.

The scroll isn't working when the TextInput is on focus. This problem is only affecting Android.

like image 273
user2427293 Avatar asked Dec 11 '22 14:12

user2427293


2 Answers

setting

<ScrollView keyboardShouldPersistTaps="always"

in combination with the textInput component below (custom component that i created for text inputs to solve this issue) solved my problem:

<TouchableOpacity
     activeOpacity={1}
     onPress={()=>this.input.focus()}>
     <View pointerEvents="none"
           <TextInput
              ref = {(input) => this.input = input}
           />
     </View>
</TouchableOpacity>
like image 80
Mahdieh Shavandi Avatar answered Jan 29 '23 01:01

Mahdieh Shavandi


In scrollView use keyboardShouldPersistTaps

<ScrollView keyboardShouldPersistTaps="handled">

it solve your problem

check docs here https://facebook.github.io/react-native/docs/scrollview.html#keyboarddismissmode

like image 43
Man Avatar answered Jan 29 '23 02:01

Man