ScrollView
A scrollable view that provides integration with the pointer-locking responder system.
ScrollView must have a bounded height: either set the height of the view directly (discouraged) or make sure all parent views have bounded height (e.g., apply { flex: 1}
down the view stack).
import { ScrollView } from 'react-native';
<ScrollView {...props}>{children}</ScrollView>;
API
Props
When true
, the scroll view automatically centers the content when the content is smaller than the scroll view bounds; when the content is larger than the scroll view, this property has no effect.
These styles will be applied to the scroll view content container which wraps all of the child views.
When true
, the default PanResponder
on the ScrollView
is disabled, and full control over pointers inside the ScrollView
is left to its child components. This is meant to be used when native “snap-to” scrolling behavior is needed.
When true
, the scroll view’s children are arranged horizontally in a row instead of vertically in a column.
Determines whether the keyboard gets dismissed in response to a scroll drag.
Called when scrollable content view of the ScrollView changes.
Called during scrolling. The frequency of the events can be controlled using the scrollEventThrottle
prop.
When true
, the scroll view snaps to individual items in the list when scrolling.
When false
, the content does not scroll.
This controls how often the scroll event will be fired while scrolling (as a time interval in ms). A lower number yields better accuracy for code that is tracking the scroll position, but can lead to scroll performance problems. The default value is 0
, which means the scroll event will be sent only once each time the view is scrolled.
An array of child indices determining which children get docked to the top of the screen when scrolling. For example, passing stickyHeaderIndices={0}
will cause the first child to be fixed to the top of the scroll view. This property is not supported in conjunction with the horizontal
prop.
ScrollEvent
The nativeEvent
on the event passed to onScroll
is a custom object of information related to the layout of the ScrollView.
How far the scroll view is scrolled along each axis.
The size of the scrollable content area.
The border-box
height and width of the scroll view.
Instant methods
Returns a reference to the underlying content container DOM node within the ScrollView
.
Returns a reference to the underlying scrollable DOM node.
Returns a reference to the underlying scroll responder, which supports operations like scrollTo()
. All ScrollView
-like components should implement this method so that they can be composed while providing access to the underlying scroll responder’s methods.
Scrolls to a given x
, y
offset (animation depends on browser support for scroll-behavior).
Scrolls to the end of the scroll view.