简体   繁体   English

React Native Android 关注 Flatlist 的粘性 ListHeaderComponent 中的 TextInput 使列表滚动 position 对齐到 y = 0

[英]React Native Android focus on TextInput inside Flatlist's sticky ListHeaderComponent makes list scroll position snap to y = 0

When running on Android, after scrolling the Flatlist and getting its content below the fixed ListHeaderComponent, when focusing the TextInput that lives inside the given header, the screen flickers and the list snaps back to scroll position y = 0.在 Android 上运行时,在滚动 Flatlist 并将其内容置于固定 ListHeaderComponent 下方后,当聚焦位于给定 header 内的 TextInput 时,屏幕闪烁并且列表快速返回滚动 Z4757FE07FD492A8DBEEZEA67A

On iOS everything runs as supposed.在 iOS 上,一切都按预期运行。

Steps to reproduce: Using the snack below, on Android, scroll the list and focus the input in the header, notice that the list snaps to new scroll position where y = 0.重现步骤: 使用下面的小吃,在 Android 上,滚动列表并将输入集中在 header 中,注意列表捕捉到新滚动 Z4757FE07FD492A8BE0EA6A760D083D6EZ。

Snack, code example, screenshot, or link to a repository: snack小吃、代码示例、屏幕截图或存储库链接:小吃

FlatList have the same props as ScrollView and on Android when you focus on the input the ScrollView scroll to the input which in your case it's the first element. FlatList具有与ScrollViewAndroid相同的道具,当您专注于输入时, ScrollView滚动到输入,在您的情况下它是第一个元素。

You can avoid that in IOS but on Android , unfortunately, there's still no way to archive it, I prefer you move the view of the header out from the FlatList if it's a requirement or you can keep it the way it's.您可以在IOS中避免这种情况,但在Android上,不幸的是,仍然无法归档它,我更喜欢您将 header 的视图移出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM