如果你的ScrollView的大小是全屏,height不能用,这种情况需要给ScrollView添加一个容器View,然后调节容器View的大小

无限轮播这里我使用的是一个第三方的插件react-native-swiper

具体可以参考https://www.npmjs.com/package/react-native-swiper

效果图

使用:

$ npm i react-native-swiper --save

代码:

import React, {Component} from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View, TouchableOpacity, Image, ScrollView
} from 'react-native';
import Swiper from 'react-native-swiper'
var Dimensions = require('Dimensions');
var {width,height} = Dimensions.get("window");//第一种写法
export default class MyApp extends Component { _onIndexChanged(index){
// alert(index)
}
render() {
return (
<View style={styles.wrapper}> <View style={styles.swiperView}>
<Swiper style={styles.swiperStyle}
showsButtons={false}//左右两边的< >箭头是否显示
horizontal={true}//是否水平滚动,默认true
loop={true}//是否轮播,默认true
index={1}//当前默认第几页,默认0
onIndexChanged={this._onIndexChanged}//当前滚动到第几页的事件
autoplayTimeout = {1} //轮播的时间
autoplay={true}//是否自动轮播,默认false
autoplayDirection={true}//是否反向轮播,默认true 左->右
showsPagination = {true} //是否显示dot
dot = {<View style={{width:8,height:8,backgroundColor:'red',marginRight: 5}}/>} //指定dot
paginationStyle = {{bottom: 10}} //dot的位置
activeDot = {<View style={{width:8,height:8,backgroundColor:'yellow',marginRight: 5}} />} //选中的dot的样式 >
<View style={styles.slide1} >
<Text style={styles.text}>Hello Swiper{width}</Text>
</View>
<View style={styles.slide2} >
<Text style={styles.text}>Beautiful</Text>
</View>
<View style={styles.slide3}>
<Text style={styles.text}>And simple</Text>
</View>
</Swiper>
</View>
</View>
)
}
} const styles = StyleSheet.create({
wrapper: {
flex: 1,
backgroundColor:"#ff0000" },
swiperView:{
width:width,
height:200,
backgroundColor:"#000000"
},
swiperStyle:{
backgroundColor:"#00ff00"
},
slide1: {
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#0000ff',
flex: 1
},
slide2: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#0000ff',
},
slide3: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#0000ff',
},
text: {
color: '#fff',
fontSize: 30,
fontWeight: 'bold',
}
});

RN无限轮播以及ScrollView的大小调节问题的更多相关文章

  1. iOS开发UI篇—无限轮播(循环利用)

    iOS开发UI篇—无限轮播(循环利用) 一.无限轮播  1.简单说明 在开发中常需要对广告或者是一些图片进行自动的轮播,也就是所谓的无限滚动. 在开发的时候,我们通常的做法是使用一个UIScrollV ...

  2. iOS开发之三个Button实现图片无限轮播(参考手机淘宝,Swift版)

    这两天使用Reveal工具查看"手机淘宝"App的UI层次时,发现其图片轮播使用了三个UIButton的复用来实现的图片循环无缝滚动.于是乎就有了今天这篇博客,看到“手机淘宝”这个 ...

  3. iOS:实现图片的无限轮播(二)---之使用第三方库SDCycleScrollView

    iOS:实现图片的无限轮播(二)---之使用第三方库SDCycleScrollView 时间:2016-01-19 19:13:43      阅读:630      评论:0      收藏:0   ...

  4. iOS开发之ImageView复用实现图片无限轮播

    在上篇博客中iOS开发之多图片无缝滚动组件封装与使用给出了图片无限轮播的实现方案之一,下面在给出另一种解决方案.今天博客中要说的就是在ScrollView上贴两个ImageView, 把ImageVi ...

  5. iOS开发UI篇—无限轮播(功能完善)

    iOS开发UI篇—无限轮播(功能完善) 一.自动滚动 添加并设置一个定时器,每个2.0秒,就跳转到下一条. 获取当前正在展示的位置. [self addNSTimer]; } -(void)addNS ...

  6. iOS 两种不同的图片无限轮播

    代码地址如下:http://www.demodashi.com/demo/11608.html 前记 其实想写这个关于无限轮播的记录已经很久很久了,只是没什么时间,这只是一个借口,正如:时间就像海绵, ...

  7. iOS项目开发之实现无限轮播

    简介 分析 实现 代码下载 一.简介 在实际的开发当中,会经常有界面需要实现图片的无限轮播这样的需求.比如新闻app,或者其他app的广告位 实现的方式有很多种,最先想动的一定是scrollView, ...

  8. iOS最笨的办法实现无限轮播图(网络加载)

    iOS最笨的办法实现无限轮播图(网络加载) 简单的做了一下: 使用方法: 把 请求返回的 图片地址(字符串类型)放进数组中就行 可以使用SDWebImage(我就是用的这个)等..需要自己导入并引用, ...

  9. iOS:实现图片的无限轮播---之使用第三方库SDCycleScrollView

    SDCycleScrollView API // //  SDCycleScrollView.h //  SDCycleScrollView #import <UIKit/UIKit.h> ...

随机推荐

  1. history 命令历史

    在终端中按捉[Ctrl]键的同时[r]键,出现提示:(reverse-i-search),此时你尝试一下输入你以前输入过的命令,当你每输入一个字符 的时候,终端都会滚动显示你的历史命令.当显示到你想找 ...

  2. vue返回上一页面如果没有上一页面返回首页

    methods: { back(){ if (window.history.length <= 1) { this.$router.push({path:'/'}) return false } ...

  3. Python 中的map、reduce函数用法

    #-*- coding:UTF-8 -*- #map()函数接受两个参数,一个是函数,一个是序列,map将传入的函数依次作用到序列的每个元素,并把结果作为新的list返回 def f(x): retu ...

  4. 【SQLSERVER】How to check current pool size

    SELECT des.program_name , des.login_name , des.host_name , COUNT(des.session_id) [Connections] FROM ...

  5. ResDepot CRC码

    参考: 百度百科 crc校验 百度百科 crc编码 生日悖论 CRC32能不能用于检验文件的相同性 Egret RES版本控制 一.Egret的ResDepot在发布时,可以添加crc码. 发布前 发 ...

  6. Android 更改按钮样式 Button Styles

    extends:http://stackoverflow.com/questions/26346727/android-material-design-button-styles   I will a ...

  7. webpack构建工具快速上手指南

    最近在研究react项目,接触到webpack打包工具.刚接触的时候一脸茫然,经过最近的学习,下面我来带大家开启webpack入门之旅. webpack是什么 webpack是近期最火的一款模块加载器 ...

  8. Spark RDD 默认分区数量 - repartitions和coalesce异同

    RDD.getNumPartitions()方法可以获得一个RDD分区数量, 1.默认由文件读取的话,本地文件会进行shuffle,hdfs文件默认会按照dfs分片来设定. 2.计算生成后,默认会按照 ...

  9. ThinkPHP框架 做个简单表单 添加数据例子__ACTION__ __SELF__

    public function zhuCe(){//自定义zhuCe方法和zhuCe显示表里的__ACTiON__这个相互交接 //实现两个逻辑 //1,显示注册页面 //2.向数据库添加内容 //自 ...

  10. svn checkout 指定目录(转)

    http://www.uqugu.com/blog/article/svn-checkout-specified-forder/ svn有时只想检出指定目录,对于其他的大文件目录则不想检出,如不想检出 ...