mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-18 04:13:51 +08:00
Make "The Basics" flow like a linear tutorial
Summary: Closes https://github.com/facebook/react-native/pull/8429 Differential Revision: D3487369 Pulled By: lacker fbshipit-source-id: 59b32f2a2a67370192c91dc43da3d4b76a43b810
This commit is contained in:
committed by
Facebook Github Bot 0
parent
0e07c36794
commit
bfb4c054f4
64
docs/UsingAScrollView.md
Normal file
64
docs/UsingAScrollView.md
Normal file
@@ -0,0 +1,64 @@
|
||||
---
|
||||
id: using-a-scrollview
|
||||
title: Using a ScrollView
|
||||
layout: docs
|
||||
category: The Basics
|
||||
permalink: docs/using-a-scrollview.html
|
||||
next: using-a-listview
|
||||
---
|
||||
|
||||
The [`ScrollView`](/react-native/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).
|
||||
|
||||
This example creates a vertical `ScrollView` with both images and text mixed together.
|
||||
|
||||
```ReactNativeWebPlayer
|
||||
import React, { Component } from 'react';
|
||||
import{ AppRegistry, ScrollView, Image, Text, View } from 'react-native'
|
||||
|
||||
class IScrolledDownAndWhatHappenedNextShockedMe extends Component {
|
||||
render() {
|
||||
return(
|
||||
<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>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
AppRegistry.registerComponent(
|
||||
'IScrolledDownAndWhatHappenedNextShockedMe',
|
||||
() => IScrolledDownAndWhatHappenedNextShockedMe);
|
||||
```
|
||||
|
||||
`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 `ListView` instead. So let's [learn about the ListView](/react-native/docs/using-a-listview.html) next.
|
||||
Reference in New Issue
Block a user