0

我有一个带有 scrollView 和很多 TextInputs 的页面,例如:

<ScrollView>
   <TextInput/>
   <TextInput/>
   <TextInput/>
   <TextInput/>
   ...
</ScrollView>

问题是:当键盘显示时,文本输入被键盘覆盖

在 Ios 上找到的不适用于 Android 的半解决方案是使用在接收焦点的 Textinput 上调用的 .measure() (OnFocus) 然后滚动到 textInput

正如你现在可能的那样, .measure 的使用方式如下:

element.measure( (fixed_x, fixed_y, width, height, page_x, page_y) => {callback} );

但是 fixed_x 和 y 每次使用 Android 时都会返回 0(我已经尝试过 https://github.com/facebook/react-native/issues/12966不透明和可折叠的错误)

我也试过这个:React native: get current scroll position of scrollview

获取 scrollView 当前滚动并添加缺少的内容以使 TextInput 可见。没有成功(不适用于 ios/android)

https://github.com/Andr3wHur5t/react-native-keyboard-spacer也不相关,因为它创建了一个大小发生变化的组件,但无助于滚动到正确的 TextInput

最后:https ://github.com/APSL/react-native-keyboard-aware-scroll-view与 ios 完美搭配,但很遗憾也不适用于 android

有人有线索吗?

4

0 回答 0