关于scrollView和android 中的使用效果是一样的 被包裹的组件和布局 能够实现滚动效果
注意:该组件适用于zi组件比较少的滚动元素
class helloReact1 extends Component { render() { return ( <ScrollView> <Text style={{fontSize:16}}>Scroll me plz</Text> <Image source={require('./img/favicon.png')} /> <Text style={{fontSize:16}}>If you like</Text> <Image source={require('./img/favicon.png')} /> <Text style={{fontSize:16}}>Scrolling down</Text> <Image source={require('./img/favicon.png')} /> <Text style={{fontSize:16}}>What's the best</Text> <Image source={require('./img/favicon.png')} /> <Text style={{fontSize:16}}>Framework around?</Text> <Image source={require('./img/favicon.png')} /> <Text style={{fontSize:80}}>React Native</Text> </ScrollView> ); } }
在项目的根目录下面创建img文件夹 将图片放入该文件夹 即可
ScrollView的深化 ---使用scrollView 实现轮播效果
需要使用的组件:Image View Scroller 定时器 Timer
关于定时器的使用方法:setTimeout clearTimeOut 每帧刷新之后执行一次
setInterval, clearInterval 稍后执行
setImmediate, clearImmediate 在当前JavaScript执行块结束的时候执行,在将要发送批量响应数据到原生之前。
requestAnimationFrame, cancelAnimationFrame 尽快的执行