android - 为什么我们在 react-native 的 View 组件中使用 removeClippedSubviews 属性?

标签 android ios reactjs react-native

为什么我们使用 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 have overflow: 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/

相关文章:

ios - Swift 检索 Firebase 数据

html - Avenir Next Condensed 在 iPad 上显示为斜体

reactjs - 如何在 Material-UI 滚动选项卡中创建自定义滚动图标

reactjs - 访问组件外部的 React 上下文

java - 等待声音结束后再继续

android - 抽屉导航 - 部分之间的分隔线,例如 Gmail 应用程序

ios - 使用自动布局时如何更改默认的 UIButton 填充

java - android listview doinbackground无法显示任何内容

java - ObjectInputStream 给我一个空对象(但读取的文件不为空)

javascript - 如何设置 refs 并为 ReactJS 中的循环元素赋值