This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
HorizontalPager
用于可滑动页面的 Jetpack Compose HorizontalPager 组件。
Expo UI HorizontalPager 与 Jetpack Compose 的 HorizontalPager 相匹配——一个水平滚动的分页器,可固定到单个页面。
HorizontalPager 不会自动设置高度——可以用 height 修饰符给它一个高度,或者把它放在有固定高度的父容器里。


安装
🌐 Installation
If you are installing this in an existing React Native app, make sure to install expo in your project.
用法
🌐 Usage
失控的
🌐 Uncontrolled
分页器本地拥有其滚动位置。使用 initialPage 选择起始页,并使用 onCurrentPageChange(在刷卡过程中目标页翻转时触发)或 onSettledPageChange(仅在刷卡结束后触发)监听变化。
🌐 The pager owns its scroll position natively. Use initialPage to pick the starting page, and listen for changes with onCurrentPageChange (fires mid-swipe as the snap target flips) or onSettledPageChange (fires only after the swipe settles).
编程导航
🌐 Programmatic navigation
附加一个 ref 并在其上调用 animateScrollToPage 或 scrollToPage。这些对应 Compose 的 PagerState.animateScrollToPage 和 PagerState.scrollToPage。
🌐 Attach a ref and call animateScrollToPage or scrollToPage on it. These mirror Compose's PagerState.animateScrollToPage and PagerState.scrollToPage.
页面间距和内容填充
🌐 Page spacing and content padding
使用 pageSpacing 在页面之间添加间隙(在滑动时可见),使用 contentPadding 插入分页器,以便在静止时邻近的页面可见。
🌐 Use pageSpacing to add a gap between pages (visible during swipe) and contentPadding to inset the pager so neighboring pages peek at rest.
应用接口
🌐 API
import { HorizontalPager } from '@expo/ui/jetpack-compose';
No API data file found, sorry!