Skip to main content

View

View 是构建 UI 的最基本组件,是一个支持 flexboxstyle一些触摸处理accessibility 控件布局的容器。View 直接映射到 React Native 运行的任何平台上的原生视图等效项,无论是 UIView<div>android.view 等。

¥The most fundamental component for building a UI, View is a container that supports layout with flexbox, style, some touch handling, and accessibility controls. View maps directly to the native view equivalent on whatever platform React Native is running on, whether that is a UIView, <div>, android.view, etc.

View 被设计为嵌套在其他视图中,并且可以有 0 到多个任何类型的子视图。

¥View is designed to be nested inside other views and can have 0 to many children of any type.

此示例创建一个 View,它将两个带有颜色的框和一个带有填充的文本组件封装在一行中。

¥This example creates a View that wraps two boxes with color and a text component in a row with padding.

View 设计为与 StyleSheet 一起使用,以提高清晰度和性能,但也支持内联样式。

¥Views are designed to be used with StyleSheet for clarity and performance, although inline styles are also supported.

合成触摸事件

¥Synthetic Touch Events

对于 View 响应者属性(例如 onResponderMove),传递给它们的合成触摸事件采用 PressEvent 的形式。

¥For View responder props (e.g., onResponderMove), the synthetic touch event passed to them are in form of PressEvent.


参考

¥Reference

属性

¥Props


accessibilityActions

辅助功能操作允许辅助技术以编程方式调用组件的操作。accessibilityActions 属性应包含操作对象的列表。每个操作对象应包含字段名称和标签。

¥Accessibility actions allow an assistive technology to programmatically invoke the actions of a component. The accessibilityActions property should contain a list of action objects. Each action object should contain the field name and label.

请参阅 无障碍指南 了解更多信息。

¥See the Accessibility guide for more information.

类型
array

accessibilityElementsHidden
iOS

指示此辅助功能元素中包含的辅助功能元素是否隐藏的值。默认为 false

¥A value indicating whether the accessibility elements contained within this accessibility element are hidden. Default is false.

请参阅 无障碍指南 了解更多信息。

¥See the Accessibility guide for more information.

类型
bool

accessibilityHint

可访问性提示可帮助用户了解当可访问性标签中的结果不明确时,他们对可访问性元素执行操作时会发生什么。

¥An accessibility hint helps users understand what will happen when they perform an action on the accessibility element when that result is not clear from the accessibility label.

类型
string

accessibilityLanguage
iOS

指示用户与元素交互时屏幕阅读器应使用哪种语言的值。它应该遵循 BCP 47 规范

¥A value indicating which language should be used by the screen reader when the user interacts with the element. It should follow the BCP 47 specification.

请参阅 iOS accessibilityLanguage 文档 了解更多信息。

¥See the iOS accessibilityLanguage doc for more information.

类型
string

accessibilityIgnoresInvertColors
iOS

指示当颜色反转打开时该视图应该或不应该反转的值。值 true 将告诉视图即使打开颜色反转也不会反转。

¥A value indicating this view should or should not be inverted when color inversion is turned on. A value of true will tell the view to not be inverted even if color inversion is turned on.

请参阅 无障碍指南 了解更多信息。

¥See the Accessibility guide for more information.

类型
bool

accessibilityLabel

当用户与元素交互时覆盖屏幕阅读器读取的文本。默认情况下,标签是通过遍历所有子节点并累加所有以空格分隔的 Text 节点来构造的。

¥Overrides the text that's read by the screen reader when the user interacts with the element. By default, the label is constructed by traversing all the children and accumulating all the Text nodes separated by space.

类型
string

accessibilityLiveRegion
Android

向辅助服务指示此视图更改时是否应通知用户。仅适用于 Android API >= 19。可能的值:

¥Indicates to accessibility services whether the user should be notified when this view changes. Works for Android API >= 19 only. Possible values:

  • 'none' - 辅助服务不应宣布对此视图的更改。

    ¥'none' - Accessibility services should not announce changes to this view.

  • 'polite'-辅助服务应宣布对此视图的更改。

    ¥'polite'- Accessibility services should announce changes to this view.

  • 'assertive' - 无障碍服务应中断正在进行的演讲,以立即宣布对此视图的更改。

    ¥'assertive' - Accessibility services should interrupt ongoing speech to immediately announce changes to this view.

请参阅 Android View 文档 以供参考。

¥See the Android View docs for reference.

类型
enum('none', 'polite', 'assertive')

accessibilityRole

accessibilityRole 将组件的用途传达给辅助技术的用户。

¥accessibilityRole communicates the purpose of a component to the user of an assistive technology.

accessibilityRole 可以是以下之一:

¥accessibilityRole can be one of the following:

  • 'none' - 当元素没有作用时使用。

    ¥'none' - Used when the element has no role.

  • 'button' - 当元素应被视为按钮时使用。

    ¥'button' - Used when the element should be treated as a button.

  • 'link' - 当元素应被视为链接时使用。

    ¥'link' - Used when the element should be treated as a link.

  • 'search' - 当文本字段元素也应被视为搜索字段时使用。

    ¥'search' - Used when the text field element should also be treated as a search field.

  • 'image' - 当元素应被视为图片时使用。例如,可以与按钮或链接组合。

    ¥'image' - Used when the element should be treated as an image. Can be combined with button or link, for example.

  • 'keyboardkey' - 当元素充当键盘按键时使用。

    ¥'keyboardkey' - Used when the element acts as a keyboard key.

  • 'text' - 当元素应被视为无法更改的静态文本时使用。

    ¥'text' - Used when the element should be treated as static text that cannot change.

  • 'adjustable' - 当元素可以是 "adjusted" 时使用(例如滑块)。

    ¥'adjustable' - Used when an element can be "adjusted" (e.g. a slider).

  • 'imagebutton' - 当元素应被视为按钮并且也是图片时使用。

    ¥'imagebutton' - Used when the element should be treated as a button and is also an image.

  • 'header' - 当元素充当内容部分的标题(例如导航栏的标题)时使用。

    ¥'header' - Used when an element acts as a header for a content section (e.g. the title of a navigation bar).

  • 'summary' - 当应用首次启动时,可以使用元素提供应用中当前状况的快速摘要时使用。

    ¥'summary' - Used when an element can be used to provide a quick summary of current conditions in the app when the app first launches.

  • 'alert' - 当元素包含要渲染给用户的重要文本时使用。

    ¥'alert' - Used when an element contains important text to be presented to the user.

  • 'checkbox' - 当元素表示可以选中、取消选中或具有混合选中状态的复选框时使用。

    ¥'checkbox' - Used when an element represents a checkbox which can be checked, unchecked, or have mixed checked state.

  • 'combobox' - 当元素表示组合框时使用,组合框允许用户在多个选项中进行选择。

    ¥'combobox' - Used when an element represents a combo box, which allows the user to select among several choices.

  • 'menu' - 当组件是选择菜单时使用。

    ¥'menu' - Used when the component is a menu of choices.

  • 'menubar' - 当组件是多个菜单的容器时使用。

    ¥'menubar' - Used when a component is a container of multiple menus.

  • 'menuitem' - 用于表示菜单中的项目。

    ¥'menuitem' - Used to represent an item within a menu.

  • 'progressbar' - 用于表示指示任务进度的组件。

    ¥'progressbar' - Used to represent a component which indicates progress of a task.

  • 'radio' - 用于表示单选按钮。

    ¥'radio' - Used to represent a radio button.

  • 'radiogroup' - 用于表示一组单选按钮。

    ¥'radiogroup' - Used to represent a group of radio buttons.

  • 'scrollbar' - 用来表示滚动条。

    ¥'scrollbar' - Used to represent a scroll bar.

  • 'spinbutton' - 用于表示打开选项列表的按钮。

    ¥'spinbutton' - Used to represent a button which opens a list of choices.

  • 'switch' - 用于表示可以打开和关闭的开关。

    ¥'switch' - Used to represent a switch which can be turned on and off.

  • 'tab' - 用于表示一个选项卡。

    ¥'tab' - Used to represent a tab.

  • 'tablist' - 用于表示选项卡列表。

    ¥'tablist' - Used to represent a list of tabs.

  • 'timer' - 用来表示计时器。

    ¥'timer' - Used to represent a timer.

  • 'toolbar' - 用于表示工具栏(操作按钮或组件的容器)。

    ¥'toolbar' - Used to represent a tool bar (a container of action buttons or components).

  • 'grid' - 与 ScrollView、VirtualizedList、FlatList 或 SectionList 一起使用来表示网格。将进入/离开网格公告添加到 android GridView。

    ¥'grid' - Used with ScrollView, VirtualizedList, FlatList, or SectionList to represent a grid. Adds the in/out of grid announcements to the android GridView.

类型
string

accessibilityState

向辅助技术的用户描述组件的当前状态。

¥Describes the current state of a component to the user of an assistive technology.

请参阅 无障碍指南 了解更多信息。

¥See the Accessibility guide for more information.

类型
目的:{disabled: bool, selected: bool, checked: bool or 'mixed', busy: bool, expanded: bool}

accessibilityValue

表示组件的当前值。它可以是组件值的文本描述,或者对于基于范围的组件(例如滑块和进度条),它包含范围信息(最小值、当前和最大值)。

¥Represents the current value of a component. It can be a textual description of a component's value, or for range-based components, such as sliders and progress bars, it contains range information (minimum, current, and maximum).

请参阅 无障碍指南 了解更多信息。

¥See the Accessibility guide for more information.

类型
目的:{min: number, max: number, now: number, text: string}

accessibilityViewIsModal
iOS

指示 VoiceOver 是否应忽略视图中与接收者同级的元素的值。默认为 false

¥A value indicating whether VoiceOver should ignore the elements within views that are siblings of the receiver. Default is false.

请参阅 无障碍指南 了解更多信息。

¥See the Accessibility guide for more information.

类型
bool

accessible

true 时,表示视图是辅助功能元素。默认情况下,所有可触摸元素都是可访问的。

¥When true, indicates that the view is an accessibility element. By default, all the touchable elements are accessible.


aria-busy

表示正在修改某个元素,并且辅助技术可能需要等到更改完成后再通知用户有关更新的信息。

¥Indicates an element is being modified and that assistive technologies may want to wait until the changes are complete before informing the user about the update.

类型默认
booleanfalse

aria-checked

指示可检查元素的状态。该字段可以采用布尔值或 "mixed" 字符串来表示混合复选框。

¥Indicates the state of a checkable element. This field can either take a boolean or the "mixed" string to represent mixed checkboxes.

类型默认
布尔值,'mixed'false

aria-disabled

指示该元素可感知但已禁用,因此不可编辑或不可操作。

¥Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable.

类型默认
booleanfalse

aria-expanded

指示可展开元素当前是展开还是折叠。

¥Indicates whether an expandable element is currently expanded or collapsed.

类型默认
booleanfalse

aria-hidden

指示此辅助功能元素中包含的辅助功能元素是否隐藏。

¥Indicates whether the accessibility elements contained within this accessibility element are hidden.

例如,在包含同级视图 AB 的窗口中,在视图 B 上将 aria-hidden 设置为 true 会导致 VoiceOver 忽略视图 B 中的元素。

¥For example, in a window that contains sibling views A and B, setting aria-hidden to true on view B causes VoiceOver to ignore the elements in the view B.

类型默认
booleanfalse

aria-label

定义一个标记交互元素的字符串值。

¥Defines a string value that labels an interactive element.

类型
string

aria-labelledby
Android

标识为其应用的元素添加标签的元素。aria-labelledby 的值应与相关元素的 nativeID 匹配:

¥Identifies the element that labels the element it is applied to. The value of aria-labelledby should match the nativeID of the related element:

<View>
<Text nativeID="formLabel">Label for Input Field</Text>
<TextInput aria-label="input" aria-labelledby="formLabel" />
</View>
类型
string

aria-live
Android

指示将更新的元素,并描述用户代理、辅助技术和用户可以从实时区域期望的更新类型。

¥Indicates that an element will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region.

  • off 辅助服务不应宣布对此视图的更改。

    ¥off Accessibility services should not announce changes to this view.

  • 礼貌的无障碍服务应该宣布对此视图的更改。

    ¥polite Accessibility services should announce changes to this view.

  • 自信的辅助服务应该中断正在进行的演讲,立即宣布对此视图的更改。

    ¥assertive Accessibility services should interrupt ongoing speech to immediately announce changes to this view.

类型默认
enum('assertive', 'off', 'polite')'off'

aria-modal
iOS

布尔值,指示 VoiceOver 是否应忽略视图中与接收者同级的元素。优先于 accessibilityViewIsModal 属性。

¥Boolean value indicating whether VoiceOver should ignore the elements within views that are siblings of the receiver. Has precedence over the accessibilityViewIsModal prop.

类型默认
booleanfalse

aria-selected

指示当前是否选择了可选元素。

¥Indicates whether a selectable element is currently selected or not.

类型
boolean

aria-valuemax

表示基于范围的组件(例如滑块和进度条)的最大值。优先于 accessibilityValue 属性中的 max 值。

¥Represents the maximum value for range-based components, such as sliders and progress bars. Has precedence over the max value in the accessibilityValue prop.

类型
number

aria-valuemin

表示基于范围的组件(例如滑块和进度条)的最小值。优先于 accessibilityValue 属性中的 min 值。

¥Represents the minimum value for range-based components, such as sliders and progress bars. Has precedence over the min value in the accessibilityValue prop.

类型
number

aria-valuenow

表示基于范围的组件(例如滑块和进度条)的当前值。优先于 accessibilityValue 属性中的 now 值。

¥Represents the current value for range-based components, such as sliders and progress bars. Has precedence over the now value in the accessibilityValue prop.

类型
number

aria-valuetext

表示组件的文本描述。优先于 accessibilityValue 属性中的 text 值。

¥Represents the textual description of the component. Has precedence over the text value in the accessibilityValue prop.

类型
string

collapsable
Android

作为优化,仅用于布局其子级或不绘制任何内容的视图可能会自动从原生层次结构中删除。将此属性设置为 false 以禁用此优化并确保此 View 存在于原生视图层次结构中。

¥Views that are only used to layout their children or otherwise don't draw anything may be automatically removed from the native hierarchy as an optimization. Set this property to false to disable this optimization and ensure that this View exists in the native view hierarchy.

类型
bool

focusable
Android

View 是否应可通过非触摸输入设备进行对焦,例如。 使用硬件键盘接收焦点。

¥Whether this View should be focusable with a non-touch input device, eg. receive focus with a hardware keyboard.

类型
boolean

hitSlop

这定义了触摸事件可以从视图开始多远。典型的界面指南建议触摸目标至少为 30 - 40 点/密度无关像素。

¥This defines how far a touch event can start away from the view. Typical interface guidelines recommend touch targets that are at least 30 - 40 points/density-independent pixels.

例如,如果可触摸视图的高度为 20,则可使用 hitSlop={{top: 10, bottom: 10, left: 0, right: 0}} 将可触摸高度扩展到 40

¥For example, if a touchable view has a height of 20 the touchable height can be extended to 40 with hitSlop={{top: 10, bottom: 10, left: 0, right: 0}}

触摸区域永远不会超出父视图边界,并且如果触摸击中两个重叠视图,则同级视图的 Z 索引始终优先。

¥The touch area never extends past the parent view bounds and the Z-index of sibling views always takes precedence if a touch hits two overlapping views.

类型
目的:{top: number, left: number, bottom: number, right: number}

id

用于从原生类中定位此视图。优先于 nativeID 属性。

¥Used to locate this view from native classes. Has precedence over nativeID prop.

这会禁用该视图的 '仅布局视图删除' 优化!

¥This disables the 'layout-only view removal' optimization for this view!

类型
string

importantForAccessibility
Android

控制视图对于辅助功能的重要性,即是否触发辅助功能事件以及是否将其报告给查询屏幕的辅助功能服务。仅适用于 Android。

¥Controls how view is important for accessibility which is if it fires accessibility events and if it is reported to accessibility services that query the screen. Works for Android only.

可能的值:

¥Possible values:

  • 'auto' - 系统确定视图对于可访问性是否重要 - 默认(推荐)。

    ¥'auto' - The system determines whether the view is important for accessibility - default (recommended).

  • 'yes' - 视图对于可访问性很重要。

    ¥'yes' - The view is important for accessibility.

  • 'no' - 视图对于可访问性并不重要。

    ¥'no' - The view is not important for accessibility.

  • 'no-hide-descendants' - 该视图对于可访问性并不重要,它的任何后代视图也不重要。

    ¥'no-hide-descendants' - The view is not important for accessibility, nor are any of its descendant views.

请参阅 Android importantForAccessibility 文档 以供参考。

¥See the Android importantForAccessibility docs for reference.

类型
enum('auto', 'yes', 'no', 'no-hide-descendants')

nativeID

用于从原生类中定位此视图。

¥Used to locate this view from native classes.

这会禁用该视图的 '仅布局视图删除' 优化!

¥This disables the 'layout-only view removal' optimization for this view!

类型
string

needsOffscreenAlphaCompositing

View 是否需要在屏幕外渲染并与 Alpha 合成,以保留 100% 正确的颜色和混合行为。默认值 (false) 会退回到绘制组件及其子组件,并将 alpha 应用于用于绘制每个元素的绘制,而不是在屏幕外渲染整个组件并使用 alpha 值将其合成回来。如果你设置不透明度的 View 具有多个重叠元素(例如多个重叠的 View,或文本和背景),则此默认值可能会很明显且不受欢迎。

¥Whether this View needs to rendered offscreen and composited with an alpha in order to preserve 100% correct colors and blending behavior. The default (false) falls back to drawing the component and its children with an alpha applied to the paint used to draw each element instead of rendering the full component offscreen and compositing it back with an alpha value. This default may be noticeable and undesired in the case where the View you are setting an opacity on has multiple overlapping elements (e.g. multiple overlapping Views, or text and a background).

对于非本地开发者来说,离屏渲染以保留正确的 alpha 行为非常昂贵且难以调试,这就是默认情况下不打开它的原因。如果你确实需要为动画启用此属性,并且视图内容是静态的(即不需要每帧重绘),请考虑将其与 renderToHardwareTextureAndroid 结合使用。如果启用该属性,则此视图将在屏幕外渲染一次,保存在硬件纹理中,然后每帧使用 alpha 合成到屏幕上,而无需在 GPU 上切换渲染目标。

¥Rendering offscreen to preserve correct alpha behavior is extremely expensive and hard to debug for non-native developers, which is why it is not turned on by default. If you do need to enable this property for an animation, consider combining it with renderToHardwareTextureAndroid if the view contents are static (i.e. it doesn't need to be redrawn each frame). If that property is enabled, this View will be rendered off-screen once, saved in a hardware texture, and then composited onto the screen with an alpha each frame without having to switch rendering targets on the GPU.

类型
bool

nextFocusDown
Android

指定当用户向下导航时接收焦点的下一个视图。参见 安卓文档

¥Designates the next view to receive focus when the user navigates down. See the Android documentation.

类型
number

nextFocusForward
Android

指定用户向前导航时接收焦点的下一个视图。参见 安卓文档

¥Designates the next view to receive focus when the user navigates forward. See the Android documentation.

类型
number

nextFocusLeft
Android

指定当用户向左导航时接收焦点的下一个视图。参见 安卓文档

¥Designates the next view to receive focus when the user navigates left. See the Android documentation.

类型
number

nextFocusRight
Android

指定当用户向右导航时接收焦点的下一个视图。参见 安卓文档

¥Designates the next view to receive focus when the user navigates right. See the Android documentation.

类型
number

nextFocusUp
Android

指定用户向上导航时接收焦点的下一个视图。参见 安卓文档

¥Designates the next view to receive focus when the user navigates up. See the Android documentation.

类型
number

onAccessibilityAction

当用户执行辅助功能操作时调用。该函数的唯一参数是一个包含要执行的操作名称的事件。

¥Invoked when the user performs the accessibility actions. The only argument to this function is an event containing the name of the action to perform.

请参阅 无障碍指南 了解更多信息。

¥See the Accessibility guide for more information.

类型
function

onAccessibilityEscape
iOS

accessibletrue 时,当用户执行退出手势时,系统将调用该函数。

¥When accessible is true, the system will invoke this function when the user performs the escape gesture.

类型
function

onAccessibilityTap

accessible 为 true 时,当用户执行辅助功能点击手势时,系统将尝试调用此函数。

¥When accessible is true, the system will try to invoke this function when the user performs accessibility tap gesture.

类型
function

onLayout

在安装和布局更改时调用。

¥Invoked on mount and on layout changes.

一旦计算出布局,就会立即触发此事件,但在接收到该事件时,新的布局可能尚未反映在屏幕上,特别是在布局动画正在进行时。

¥This event is fired immediately once the layout has been calculated, but the new layout may not yet be reflected on the screen at the time the event is received, especially if a layout animation is in progress.

类型
({nativeEvent: LayoutEvent}) => void

onMagicTap
iOS

accessibletrue 时,当用户执行 magic tap 手势时系统将调用该函数。

¥When accessible is true, the system will invoke this function when the user performs the magic tap gesture.

类型
function

onMoveShouldSetResponder

此视图是否想要 "claim" 触摸响应能力?当 View 不是响应者时,每次触摸移动都会调用此方法。

¥Does this view want to "claim" touch responsiveness? This is called for every touch move on the View when it is not the responder.

类型
({nativeEvent: PressEvent}) => boolean

onMoveShouldSetResponderCapture

如果父 View 想要阻止子 View 在移动时成为响应者,它应该有一个返回 true 的处理程序。

¥If a parent View wants to prevent a child View from becoming responder on a move, it should have this handler which returns true.

类型
({nativeEvent: PressEvent}) => boolean

onResponderGrant

视图现在正在响应触摸事件。现在是高亮并向用户展示正在发生的事情的时候了。

¥The View is now responding for touch events. This is the time to highlight and show the user what is happening.

在 Android 上,从此回调返回 true,以防止任何其他原生组件成为响应者,直到该响应者终止。

¥On Android, return true from this callback to prevent any other native components from becoming responder until this responder terminates.

类型
({nativeEvent: PressEvent}) => void | boolean

onResponderMove

用户正在移动手指。

¥The user is moving their finger.

类型
({nativeEvent: PressEvent}) => void

onResponderReject

另一个响应者已经处于活动状态,不会将其释放给请求成为响应者的 View

¥Another responder is already active and will not release it to that View asking to be the responder.

类型
({nativeEvent: PressEvent}) => void

onResponderRelease

在触摸结束时触发。

¥Fired at the end of the touch.

类型
({nativeEvent: PressEvent}) => void

onResponderTerminate

应答器已从 View 上取下。可能会在调用 onResponderTerminationRequest 后被其他视图获取,或者可能会被操作系统在没有询问的情况下获取(例如,发生在 iOS 上的控制中心/通知中心)

¥The responder has been taken from the View. Might be taken by other views after a call to onResponderTerminationRequest, or might be taken by the OS without asking (e.g., happens with control center/ notification center on iOS)

类型
({nativeEvent: PressEvent}) => void

onResponderTerminationRequest

其他一些 View 想要成为响应者并要求该 View 释放其响应者。返回 true 允许其释放。

¥Some other View wants to become responder and is asking this View to release its responder. Returning true allows its release.

类型
({nativeEvent: PressEvent}) => void

onStartShouldSetResponder

这个视图是否想在触摸开始时成为响应者?

¥Does this view want to become responder on the start of a touch?

类型
({nativeEvent: PressEvent}) => boolean

onStartShouldSetResponderCapture

如果父 View 想要阻止子 View 在触摸启动时成为响应者,它应该有一个返回 true 的处理程序。

¥If a parent View wants to prevent a child View from becoming responder on a touch start, it should have this handler which returns true.

类型
({nativeEvent: PressEvent}) => boolean

pointerEvents

控制 View 是否可以作为触摸事件的目标。

¥Controls whether the View can be the target of touch events.

  • 'auto':View 可以是触摸事件的目标。

    ¥'auto': The View can be the target of touch events.

  • 'none':视图永远不是触摸事件的目标。

    ¥'none': The View is never the target of touch events.

  • 'box-none':View 永远不是触摸事件的目标,但它的子视图可以。它的行为就像视图在 CSS 中具有以下类一样:

    ¥'box-none': The View is never the target of touch events but its subviews can be. It behaves like if the view had the following classes in CSS:

.box-none {
pointer-events: none;
}
.box-none * {
pointer-events: auto;
}
  • 'box-only':视图可以是触摸事件的目标,但其子视图不能。它的行为就像视图在 CSS 中具有以下类一样:

    ¥'box-only': The view can be the target of touch events but its subviews cannot be. It behaves like if the view had the following classes in CSS:

.box-only {
pointer-events: auto;
}
.box-only * {
pointer-events: none;
}
类型
enum('box-none', 'none', 'box-only', 'auto')

removeClippedSubviews

这是 RCTView 公开的保留性能属性,当有许多子视图(其中大部分位于屏幕外)时,对于滚动内容很有用。为了使该属性有效,必须将其应用于包含许多延伸到其边界之外的子视图的视图。子视图也必须具有 overflow: hidden,包含视图(或其超级视图之一)也应该具有 overflow: hidden

¥This is a reserved 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).

类型
bool

renderToHardwareTextureAndroid
Android

View 是否应将自身(及其所有子级)渲染为 GPU 上的单个硬件纹理。

¥Whether this View should render itself (and all of its children) into a single hardware texture on the GPU.

在 Android 上,这对于仅修改不透明度、旋转、平移和/或缩放的动画和交互非常有用:在这些情况下,不需要重新绘制视图,也不需要重新执行显示列表。纹理可以重复使用并使用不同的参数重新合成。缺点是这会耗尽有限的视频内存,因此应在交互/动画结束时将此属性设置回 false。

¥On Android, this is useful for animations and interactions that only modify opacity, rotation, translation, and/or scale: in those cases, the view doesn't have to be redrawn and display lists don't need to be re-executed. The texture can be re-used and re-composited with different parameters. The downside is that this can use up limited video memory, so this prop should be set back to false at the end of the interaction/animation.

类型
bool

role

role 将组件的用途传达给辅助技术的用户。优先于 accessibilityRole 属性。

¥role communicates the purpose of a component to the user of an assistive technology. Has precedence over the accessibilityRole prop.

类型
角色

shouldRasterizeIOS
iOS

合成前是否应将此 View 渲染为位图。

¥Whether this View should be rendered as a bitmap before compositing.

在 iOS 上,这对于不修改此组件的尺寸及其子组件的动画和交互非常有用;例如,当转换静态视图的位置时,光栅化允许渲染器重用静态视图的缓存位图并在每个帧期间快速合成它。

¥On iOS, this is useful for animations and interactions that do not modify this component's dimensions nor its children; for example, when translating the position of a static view, rasterization allows the renderer to reuse a cached bitmap of a static view and quickly composite it during each frame.

光栅化会产生离屏绘图过程,并且位图会消耗内存。使用此属性时进行测试和测量。

¥Rasterization incurs an off-screen drawing pass and the bitmap consumes memory. Test and measure when using this property.

类型
bool

style

类型
View 样式

tabIndex
Android

View 是否应可通过非触摸输入设备进行对焦,例如。 使用硬件键盘接收焦点。支持以下值:

¥Whether this View should be focusable with a non-touch input device, eg. receive focus with a hardware keyboard. Supports the following values:

  • 0 - 视图可聚焦

    ¥0 - View is focusable

  • -1 - 视图无法聚焦

    ¥-1 - View is not focusable

类型
enum(0, -1)

testID

用于在端到端测试中定位此视图。

¥Used to locate this view in end-to-end tests.

这会禁用该视图的 '仅布局视图删除' 优化!

¥This disables the 'layout-only view removal' optimization for this view!

类型
string