- 第1节:React 入门
- 第2节:React 安装 Android 运行环境
- 第3节:React Native 样式
- 第4节:React Native 手势应答系统
- 第5节:React Native 辅助功能
- 第6节:React Native 模块(iOS)
- 第7节:React Native UI 组件(iOS)
- 第8节:React Native UI 组件(Android)
- 第9节:React Native 调试 React Native 应用
- 第10节:React Native 测试
- 第11节:React Native 在设备上运行
- 第12节:React Native 在设备上运行(Android)
- 第13节:React Native 与现有的应用程序集成
- 第14节:React Native JavaScript 环境
- 第15节:React Native 已知 Issues
- 第16节:React Native iOS 活动指示器
- 第17节:React Native iOS 日期选择器
- 第18节:React Native DrawerLayoutAndroid
- 第19节:React Native 图片
- 第20节:React Native 列表视图
- 第21节:React Native Map 视图
- 第22节:React Native 导航器
- 第23节:React Native iOS 导航器
- 第24节:React Native iOS 选择器
- 第25节:React Native ProgressBarAndroid
- 第26节:React Native 滚动视图
- 第27节:React Native iOS 滑块
- 第28节:React Native SwitchAndroid
- 第29节:React Native iOS 开关
- 第30节:React Native iOS 选项卡
- 第31节:React Native TabBarIOS.Item
- 第32节:React Native 文本
- 第33节:React Native 文本输入
- 第34节:React Native ToolbarAndroid
- 第35节:React Native 高亮触摸
- 第36节:React Native 不透明触摸
- 第37节:React Native 无反馈触摸
- 第38节:React Native 视图
- 第39节:React Native Web 视图
- 第40节:React Native iOS 警告
- 第41节:React Native 应用程序注册表
- 第42节:React Native iOS 应用程序状态
- 第43节:React Native 异步存储
- 第44节:React Native BackAndroid
- 第45节:React Native 相机滚动
- 第46节:React Native 交互管理器
- 第47节:React Native 动画布局
- 第48节:React Native iOS 链接
- 第49节:React Native 网络信息
- 第50节:React Native 全景响应器
- 第51节:React Native 像素比率
- 第52节:React Native iOS 推送通知
- 第53节:React Native iOS 状态栏
- 第54节:React Native 样式表
- 第55节:React Native ToastAndroid
- 第56节:React Native iOS 震动
- 第57节:React Native Flexbox
- 第58节:React Native 定位
- 第59节:React Native 网络
- 第60节:React Native 计时器
React Native 滚动视图
组件封装了滚动视图平台,同时提供了与锁定“应答”系统的触摸的集成。
尚不支持其他来自阻止滚动视图成为响应者的包含的响应。
Props
Edit on GitHub
alwaysBounceHorizontal 布尔型
当为真时,滚动视图到达内容底部时,水平反弹,即使该内容小于滚动视图。当 horizontal={true}
时,默认值为 true,否则,默认值为 false。
alwaysBounceVertical 布尔型
当为真时,滚动视图到达内容底部时,垂直反弹,即使该内容小于滚动视图。当 horizontal={true}
时,默认值为 false,否则,默认值为 true。
automaticallyAdjustContentInsets 布尔型
bounces 布尔型
当为真时,当滚动视图到达内容底部时,反弹,如果内容比滚动视图是大,那么滚动视图沿着轴滚动方向反弹。当为假时,禁用所有反弹,即使 alwaysBounce *
道具为真。默认值为 true。
centerContent bool 布尔型
当为真时,当内容小于滚动视图边界时,滚动视图自动的集中内容;当内容大于滚动视图时,该属性没有任何影响。默认值是 false。
contentContainerStyle StyleSheetPropType(ViewStylePropTypes)
这些样式将应用到滚动视图内容容器中,内容容器包装了所有的子视图。例如:
return ( <ScrollView contentContainerStyle={styles.contentContainer}> </ScrollView> ); ... var styles = StyleSheet.create({ contentContainer: { paddingVertical: 20 } });
contentInset {顶部:数字型,左部:数字型,底部:数字型,右部:数字型}
contentOffset PointPropType
decelerationRate 数字型
一个浮点数,决定了在用户移开手指后,滚动视图减速有多快。合理的选择包括——正常:0.998(默认)——快速:0.9
horizontal 布尔型
当为真时,滚动视图的子视图水平排列为一行,而不是竖直排列为一列。默认值是 false。
keyboardDismissMode 枚举型(“none”,“interactive”,“onDrag”)
确定键盘在响应一个拖动时是否被摒弃。——“none”(默认),拖动没有摒弃键盘。——“onDrag”,当拖动开始时键盘就被摒弃了。——“interactive”,键盘被拖动交互式地摒弃并且与触摸同步移动;向上拖动取消了摒弃。
keyboardShouldPersistTaps 布尔型
当为假时,当键盘向上摒弃键盘时,轻击外部关注文本输入。当为真时,滚动视图不会抓取轻击,键盘不会自动摒弃。默认值是 false。
maximumZoomScale 数字型
最大允许缩放比例。默认值是 1.0。
minimumZoomScale 数字型
最小允许缩放比例。默认值是 1.0。
onScroll 函数型
onScrollAnimationEnd 函数型
pagingEnabled 布尔型
当为真时,滚动视图在滚动时会在滚动视图的尺寸的倍数上停止滚动。这可以用于水平分页。默认值是 false。
removeClippedSubviews 布尔型
实验:当为真时,屏幕以外的子视图(它的 overflow
值是 `hidden )从本地备份的 superview 中删除。这在长列表中可以提高滚动性能。默认值是 false。
scrollEnabled 布尔型
scrollEventThrottle 数字型
scrollIndicatorInsets {顶部:数字型,左部:数字型,底部:数字型,右部:数字型}
scrollsToTop 布尔型
当为真时,轻击状态栏滚动视图会滚动到顶部。默认值为 true。
showsHorizontalScrollIndicator 布尔型
showsVerticalScrollIndicator 布尔型
stickyHeaderIndices [数字型]
一组子视图表明确定当视图滚动时哪些子视图会停靠在屏幕的顶端。例如,传递 stickyHeaderIndices = {[0]}
将使得第一个子视图固定在滚动视图的顶部。此属性不支持与 horizontal = {true}
结合。
style style
Flexbox...
backgroundColor 字符串型
borderBottomColor 字符串型
borderColor 字符串型
borderLeftColor 字符串型
borderRadius 数字型
borderRightColor 字符串型
borderTopColor 字符串型
opacity 数字型
overflow 枚举型(‘visible’,’hidden’)
rotation 数字型
scaleX 数字型
scaleY 数字型
shadowColor 字符串型
shadowOffset {高:数字型,宽:数字型}
shadowOpacity 数字型
shadowRadius 数字型
transformMatrix [数字型]
translateX 数字型
translateY 数字型
zoomScale 数字型
当前滚动视图内容的规模。默认值是 1.0。
例子
Edit on GitHub
'use strict';var React = require('react-native');var {
ScrollView,
StyleSheet,
View,
Image
} = React;
exports.title = '<ScrollView>';
exports.description = 'Component that enables scrolling through child components';
exports.examples = [
{
title: '<ScrollView>',
description: 'To make content scrollable, wrap it within a <ScrollView> component',
render: function() { return ( <ScrollView
onScroll={() => { console.log('onScroll!'); }}
scrollEventThrottle={200}
contentInset={{top: -50}}
style={styles.scrollView}>
{THUMBS.map(createThumbRow)} </ScrollView>
);
}
}, {
title: '<ScrollView> (horizontal = true)',
description: 'You can display <ScrollView>\'s child components horizontally rather than vertically',
render: function() { return ( <ScrollView
horizontal={true}
contentInset={{top: -50}} style={[styles.scrollView, styles.horizontalScrollView]}>
{THUMBS.map(createThumbRow)} </ScrollView>
);
}
}];var Thumb = React.createClass({
shouldComponentUpdate: function(nextProps, nextState) { return false;
},
render: function() { return ( <View style={styles.button}>
<Image style={styles.img} source={{uri:this.props.uri}} />
</View>
);
}
});var THUMBS = ['https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-ash3/t39.1997/p128x128/851549_767334479959628_274486868_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851561_767334496626293_1958532586_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-ash3/t39.1997/p128x128/851579_767334503292959_179092627_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851589_767334513292958_1747022277_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851563_767334559959620_1193692107_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851593_767334566626286_1953955109_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851591_767334523292957_797560749_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851567_767334529959623_843148472_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851548_767334489959627_794462220_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851575_767334539959622_441598241_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-ash3/t39.1997/p128x128/851573_767334549959621_534583464_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851583_767334573292952_1519550680_n.png'];
THUMBS = THUMBS.concat(THUMBS); // double length of THUMBSvar createThumbRow = (uri, i) => <Thumb key={i} uri={uri} />;var styles = StyleSheet.create({
scrollView: {
backgroundColor: '#6A85B1',
height: 300,
},
horizontalScrollView: {
height: 120,
},
containerPage: {
height: 50,
width: 50,
backgroundColor: '#527FE4',
padding: 5,
},
text: {
fontSize: 20,
color: '#888888',
left: 80,
top: 20,
height: 40,
},
button: {
margin: 7,
padding: 5,
alignItems: 'center',
backgroundColor: '#eaeaea',
borderRadius: 3,
},
buttonContents: {
flexDirection: 'row',
width: 64,
height: 64,
},
img: {
width: 64,
height: 64,
}
});