当焦点文本输入反应原生时,scrollview 无法滚动

use*_*293 4 textinput scrollview android-edittext react-native react-native-scrollview

我在 ScrollView 中有一个 TextInput。

当 TextInput 处于焦点时,滚动不起作用。此问题仅影响 Android。

Mah*_*ndi 8

环境

<ScrollView keyboardShouldPersistTaps="always"

结合下面的 textInput 组件(我为文本输入创建的自定义组件以解决此问题)解决了我的问题:

<TouchableOpacity
     activeOpacity={1}
     onPress={()=>this.input.focus()}>
     <View pointerEvents="none"
           <TextInput
              ref = {(input) => this.input = input}
           />
     </View>
</TouchableOpacity>
Run Code Online (Sandbox Code Playgroud)

  • 警告:此方法有效地禁用文本选择,因此用户无法复制/粘贴或将光标放在文本中间。 (2认同)