为什么我们使用 removeClippedSubviews
View
中的属性(property)react-native 中的组件及其作用?文件说:
This is a special performance property exposed by
RCTView
and is useful for scrolling content when there are many subviews, most of which are offscreen. For this property to be effective, it must be applied to a view that contains many subviews that extend outside its bound. The subviews must also haveoverflow: hidden
, as should the containing view (or one of its superviews).
documentation似乎无法理解。谁能用一个小例子解释一下?
最佳答案
将 removeClippedSubviews 设置为 false 修复了一个可怕的问题,即如果您在 FlatList 中使用 TextInput,Android 键盘会消失,并且点击的 TextInput 位于即将成为键盘区域的下方。
(我什至在 React Native 文档示例中重现了这一点,我只是在虚拟 android 上运行了一个示例并将 Text 更改为 TextInput。)
我假设即将在键盘下方的 subview 被删除,因为它们即将被键盘剪切,导致键盘立即离开,因为不再呈现 TextInput。
因此,至少在 FlatList 上,该属性有一个(在我的情况下)关键用途。
关于android - 为什么我们在 react-native 的 View 组件中使用 removeClippedSubviews 属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53374580/