常用属性
- horizontal={true} 水平排列 (如果不写默认的是竖向)
- showsHorizontalScrollIndicator 不显示横向滚动条(用小数点代替)
- pagingEnabled={true} 滚动条倍数滚动(类似与滑动一页)
这是最常用的三个,当然有很多属性 点击参考官网
举例代码如下:
import React, { Component } from 'react'
import { View,ScrollView,TextInput,Image,Text,StyleSheet,TouchableOpacity,Dimensions } from 'react-native'
export default class App5 extends Component {
render() {
return (
<View >
{/* showsHorizontalScrollIndicator 不显示横向滚动条(用小数点代替)
horizontal={true} 水平排列
pagingEnabled={true} 滚动条倍数滚动(类似与滑动一页)
*/}
<ScrollView showsHorizontalScrollIndicator={false} horizontal={true} pagingEnabled={true}>
<View style={styles.box1}></View>
<View style={styles.box2}></View>
</ScrollView>
</View>
)
}
}
const styles=StyleSheet.create({
box1:{
width:360,
height:150,
backgroundColor:"#ccc"
},
box2:{
width:360,
height:150,
backgroundColor:"pink"
}
})