組件封裝了滾動(dòng)視圖平臺(tái),同時(shí)提供了與鎖定“應(yīng)答”系統(tǒng)的觸摸的集成。
尚不支持其他來自阻止?jié)L動(dòng)視圖成為響應(yīng)者的包含的響應(yīng)。
alwaysBounceHorizontal 布爾型
當(dāng)為真時(shí),滾動(dòng)視圖到達(dá)內(nèi)容底部時(shí),水平反彈,即使該內(nèi)容小于滾動(dòng)視圖。當(dāng) horizontal={true}
時(shí),默認(rèn)值為 true,否則,默認(rèn)值為 false。
alwaysBounceVertical 布爾型
當(dāng)為真時(shí),滾動(dòng)視圖到達(dá)內(nèi)容底部時(shí),垂直反彈,即使該內(nèi)容小于滾動(dòng)視圖。當(dāng) horizontal={true}
時(shí),默認(rèn)值為 false,否則,默認(rèn)值為 true。
automaticallyAdjustContentInsets 布爾型
bounces 布爾型
當(dāng)為真時(shí),當(dāng)滾動(dòng)視圖到達(dá)內(nèi)容底部時(shí),反彈,如果內(nèi)容比滾動(dòng)視圖是大,那么滾動(dòng)視圖沿著軸滾動(dòng)方向反彈。當(dāng)為假時(shí),禁用所有反彈,即使 alwaysBounce *
道具為真。默認(rèn)值為 true。
centerContent bool 布爾型
當(dāng)為真時(shí),當(dāng)內(nèi)容小于滾動(dòng)視圖邊界時(shí),滾動(dòng)視圖自動(dòng)的集中內(nèi)容;當(dāng)內(nèi)容大于滾動(dòng)視圖時(shí),該屬性沒有任何影響。默認(rèn)值是 false。
contentContainerStyle StyleSheetPropType(ViewStylePropTypes)
這些樣式將應(yīng)用到滾動(dòng)視圖內(nèi)容容器中,內(nèi)容容器包裝了所有的子視圖。例如:
return ( <ScrollView contentContainerStyle={styles.contentContainer}> </ScrollView> ); ... var styles = StyleSheet.create({ contentContainer: { paddingVertical: 20 } });
contentInset {頂部:數(shù)字型,左部:數(shù)字型,底部:數(shù)字型,右部:數(shù)字型}
contentOffset PointPropType
decelerationRate 數(shù)字型
一個(gè)浮點(diǎn)數(shù),決定了在用戶移開手指后,滾動(dòng)視圖減速有多快。合理的選擇包括——正常:0.998(默認(rèn))——快速:0.9
horizontal 布爾型
當(dāng)為真時(shí),滾動(dòng)視圖的子視圖水平排列為一行,而不是豎直排列為一列。默認(rèn)值是 false。
keyboardDismissMode 枚舉型(“none”,“interactive”,“onDrag”)
確定鍵盤在響應(yīng)一個(gè)拖動(dòng)時(shí)是否被摒棄。——“none”(默認(rèn)),拖動(dòng)沒有摒棄鍵盤。——“onDrag”,當(dāng)拖動(dòng)開始時(shí)鍵盤就被摒棄了?!癷nteractive”,鍵盤被拖動(dòng)交互式地摒棄并且與觸摸同步移動(dòng);向上拖動(dòng)取消了摒棄。
keyboardShouldPersistTaps 布爾型
當(dāng)為假時(shí),當(dāng)鍵盤向上摒棄鍵盤時(shí),輕擊外部關(guān)注文本輸入。當(dāng)為真時(shí),滾動(dòng)視圖不會(huì)抓取輕擊,鍵盤不會(huì)自動(dòng)摒棄。默認(rèn)值是 false。
maximumZoomScale 數(shù)字型
最大允許縮放比例。默認(rèn)值是 1.0。
minimumZoomScale 數(shù)字型
最小允許縮放比例。默認(rèn)值是 1.0。
onScroll 函數(shù)型
onScrollAnimationEnd 函數(shù)型
pagingEnabled 布爾型
當(dāng)為真時(shí),滾動(dòng)視圖在滾動(dòng)時(shí)會(huì)在滾動(dòng)視圖的尺寸的倍數(shù)上停止?jié)L動(dòng)。這可以用于水平分頁。默認(rèn)值是 false。
removeClippedSubviews 布爾型
實(shí)驗(yàn):當(dāng)為真時(shí),屏幕以外的子視圖(它的 overflow
值是 `hidden )從本地備份的 superview 中刪除。這在長(zhǎng)列表中可以提高滾動(dòng)性能。默認(rèn)值是 false。
scrollEnabled 布爾型
scrollEventThrottle 數(shù)字型
scrollIndicatorInsets {頂部:數(shù)字型,左部:數(shù)字型,底部:數(shù)字型,右部:數(shù)字型}
scrollsToTop 布爾型
當(dāng)為真時(shí),輕擊狀態(tài)欄滾動(dòng)視圖會(huì)滾動(dòng)到頂部。默認(rèn)值為 true。
showsHorizontalScrollIndicator 布爾型
showsVerticalScrollIndicator 布爾型
stickyHeaderIndices [數(shù)字型]
一組子視圖表明確定當(dāng)視圖滾動(dòng)時(shí)哪些子視圖會(huì)??吭谄聊坏捻敹恕@?,傳遞 stickyHeaderIndices = {[0]}
將使得第一個(gè)子視圖固定在滾動(dòng)視圖的頂部。此屬性不支持與 horizontal = {true}
結(jié)合。
style style
backgroundColor 字符串型
borderBottomColor 字符串型
borderColor 字符串型
borderLeftColor 字符串型
borderRadius 數(shù)字型
borderRightColor 字符串型
borderTopColor 字符串型
opacity 數(shù)字型
overflow 枚舉型(‘visible’,’hidden’)
rotation 數(shù)字型
scaleX 數(shù)字型
scaleY 數(shù)字型
shadowColor 字符串型
shadowOffset {高:數(shù)字型,寬:數(shù)字型}
shadowOpacity 數(shù)字型
shadowRadius 數(shù)字型
transformMatrix [數(shù)字型]
translateX 數(shù)字型
translateY 數(shù)字型
zoomScale 數(shù)字型
當(dāng)前滾動(dòng)視圖內(nèi)容的規(guī)模。默認(rèn)值是 1.0。
'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, } });
更多建議: