2016-06-26 19:30:58 +00:00
---
id: using-a-scrollview
title: Using a ScrollView
layout: docs
category: The Basics
permalink: docs/using-a-scrollview.html
next: using-a-listview
2016-07-13 21:45:53 +00:00
previous: handling-text-input
2016-06-26 19:30:58 +00:00
---
2017-01-31 20:07:15 +00:00
The [`ScrollView` ](docs/scrollview.html ) is a generic scrolling container that can host multiple components and views. The scrollable items need not be homogenous, and you can scroll both vertically and horizontally (by setting the `horizontal` property).
2016-06-26 19:30:58 +00:00
This example creates a vertical `ScrollView` with both images and text mixed together.
```ReactNativeWebPlayer
import React, { Component } from 'react';
2017-05-28 20:41:49 +00:00
import { AppRegistry, ScrollView, Image, Text } from 'react-native';
2016-06-26 19:30:58 +00:00
2017-05-17 06:43:46 +00:00
export default class IScrolledDownAndWhatHappenedNextShockedMe extends Component {
2016-06-26 19:30:58 +00:00
render() {
2017-02-28 14:11:23 +00:00
return (
2016-06-26 19:30:58 +00:00
< ScrollView >
< Text style = {{fontSize:96}} > Scroll me plz< / Text >
< Image source = {require('./img/favicon.png')} / >
< Image source = {require('./img/favicon.png')} / >
< Image source = {require('./img/favicon.png')} / >
< Image source = {require('./img/favicon.png')} / >
< Image source = {require('./img/favicon.png')} / >
< Text style = {{fontSize:96}} > If you like< / Text >
< Image source = {require('./img/favicon.png')} / >
< Image source = {require('./img/favicon.png')} / >
< Image source = {require('./img/favicon.png')} / >
< Image source = {require('./img/favicon.png')} / >
< Image source = {require('./img/favicon.png')} / >
< Text style = {{fontSize:96}} > Scrolling down< / Text >
< Image source = {require('./img/favicon.png')} / >
< Image source = {require('./img/favicon.png')} / >
< Image source = {require('./img/favicon.png')} / >
< Image source = {require('./img/favicon.png')} / >
< Image source = {require('./img/favicon.png')} / >
< Text style = {{fontSize:96}} > What's the best< / Text >
< Image source = {require('./img/favicon.png')} / >
< Image source = {require('./img/favicon.png')} / >
< Image source = {require('./img/favicon.png')} / >
< Image source = {require('./img/favicon.png')} / >
< Image source = {require('./img/favicon.png')} / >
< Text style = {{fontSize:96}} > Framework around?< / Text >
< Image source = {require('./img/favicon.png')} / >
< Image source = {require('./img/favicon.png')} / >
< Image source = {require('./img/favicon.png')} / >
< Image source = {require('./img/favicon.png')} / >
< Image source = {require('./img/favicon.png')} / >
< Text style = {{fontSize:80}} > React Native< / Text >
< / ScrollView >
);
}
}
2017-05-17 06:43:46 +00:00
// skip these lines if using Create React Native App
2016-06-26 19:30:58 +00:00
AppRegistry.registerComponent(
2017-05-30 21:12:00 +00:00
'AwesomeProject',
2016-06-26 19:30:58 +00:00
() => IScrolledDownAndWhatHappenedNextShockedMe);
```
2017-06-02 19:37:51 +00:00
`ScrollView` works best to present a small amount 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 more items that can fit on the screen, you should use a `FlatList` instead. So let's [learn about list views ](docs/using-a-listview.html ) next.