This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
LazyRow
用于显示水平滚动列表的 Jetpack Compose LazyRow 组件。
Expo UI 的 LazyRow 与官方 Jetpack Compose LazyRow API 一致,显示一个横向滚动的列表。
🌐 Expo UI LazyRow matches the official Jetpack Compose LazyRow API and displays a horizontally scrolling list.


安装
🌐 Installation
If you are installing this in an existing React Native app, make sure to install expo in your project.
用法
🌐 Usage
基础懒惰行
🌐 Basic lazy row
[LazyRow](#lazyrow) 的每个子元素都是一个条目。使用 horizontalArrangement 属性来调整条目之间的间距,使用 contentPadding 属性来给列表内容添加内边距。
🌐 Each child of LazyRow is one item. Use the horizontalArrangement prop to space the items and the contentPadding prop to add padding around the list content.
大型列表
🌐 Large lists
使用 LazyRow.Items 来渲染数组中的项目。把项目作为 data 传入,每个项目用 keyExtractor 提供唯一的 key,并提供一个 children 函数来返回项目的视图。LazyRow.Items 只渲染靠近可见区域的项目,并在你滚动时重复使用它们。
🌐 Use LazyRow.Items to render items from an array. Pass the items as data, a unique key for each item with keyExtractor, and a children function that returns the view for an item. LazyRow.Items renders only the items near the visible area and reuses them while you scroll.
在展示物品时遵守这些规则:
🌐 Follow these rules when you render items:
- 给
LazyRow设置固定高度。还没准备好的项目显示一个空占位符,填满整行的高度。 - 在组件外定义
children函数,或者把它包在useCallback里。否则,每次组件渲染时,可见区域附近的项都会重新渲染。 - 一个重用的视图会保留它之前显示的项目的本地状态(
useState)。当项目改变时重置状态,或者把状态保存在视图外部。 - 将
estimatedItemSize设置为接近你物品宽度的数值,单位是独立像素(dp)。 - 使用
overscanCount来在可见项目的前后准备更多项目。 - 要更新项目,传入一个新的
data数组。不要在原地修改数组。 - 把
recycling={false}设置成提前渲染每一项。
应用接口
🌐 API
import { LazyRow } from '@expo/ui/jetpack-compose';
No API data file found, sorry!