当焦点textinput反应原生时,scrollview无法滚动

问题描述 投票:2回答:4

我在ScrollView中有一个TextInput。

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

android-edittext react-native scrollview textinput react-native-scrollview
4个回答
3
投票

设置

<ScrollView keyboardShouldPersistTaps="always"

结合下面的textInout组件(我为文本输入创建的自定义组件来解决这个问题)解决了我的问题:

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

1
投票

在scrollView中使用keyboardShouldPersistTaps

<ScrollView keyboardShouldPersistTaps="handled">

它解决了你的问题

在这里查看文档https://facebook.github.io/react-native/docs/scrollview.html#keyboarddismissmode


0
投票

这是预期的行为。

有关Official TextInput documentation的更多信息

您可能想尝试这样的事情:react-native-aware-scroll-view


0
投票

这是一个很好的例子:http://blog.arjun.io/react-native/mobile/cross-platform/2016/04/01/handling-the-keyboard-in-react-native.html

对我来说真正重要的是添加:

机器人:windowSoftInputMode = “adjustResize”

在AndroidManifest.xml中以便关注textInput

© www.soinside.com 2019 - 2024. All rights reserved.