Skip to main content

使用滚动视图

ScrollView 是一个通用的滚动容器,可以包含多个组件和视图。可滚动项目可以是异构的,并且你可以垂直和水平滚动(通过设置 horizontal 属性)。

¥The ScrollView is a generic scrolling container that can contain multiple components and views. The scrollable items can be heterogeneous, and you can scroll both vertically and horizontally (by setting the horizontal property).

此示例创建一个垂直 ScrollView,其中图片和文本混合在一起。

¥This example creates a vertical ScrollView with both images and text mixed together.

ScrollViews 可以配置为允许使用 pagingEnabled 属性通过滑动手势对视图进行分页。在 Android 上,也可以使用 ViewPager 组件在视图之间水平滑动。

¥ScrollViews can be configured to allow paging through views using swiping gestures by using the pagingEnabled props. Swiping horizontally between views can also be implemented on Android using the ViewPager component.

在 iOS 上,带有单个项目的 ScrollView 可用于允许用户缩放内容。设置 maximumZoomScaleminimumZoomScale 属性,你的用户将能够使用捏合和展开手势来放大和缩小。

¥On iOS a ScrollView with a single item can be used to allow the user to zoom content. Set up the maximumZoomScale and minimumZoomScale props and your user will be able to use pinch and expand gestures to zoom in and out.

ScrollView 最适合渲染少量大小有限的内容。ScrollView 的所有元素和视图都会被渲染,即使它们当前未显示在屏幕上。如果你有一长串项目无法显示在屏幕上,则应使用 FlatList。接下来让我们 了解列表视图

¥The ScrollView works best to present a small number of things of a limited size. All the elements and views of a ScrollView are rendered, even if they are not currently shown on the screen. If you have a long list of items which cannot fit on the screen, you should use a FlatList instead. So let's learn about list views next.