如果你的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. 正确释放WORD对象(COM组件) COMException: 被调用的对象已与其客户端断开连接

    本来form method=post本页面 修改为其他页面 action=save.aspx后没问题 其他问题可参考以下: 引自:http://topic.csdn.net/u/20090108/17 ...

  2. How do I convert an enum to a list in C#?

    How do I convert an enum to a list in C#? This will return an IEnumerable<SomeEnum> of all the ...

  3. Git合并最近的commit

    合并commit的做法一般用在pull request的时候,把开发同一功能时的所有琐碎的commit合并到一个(假装自己的代码是高质量代码(手动滑稽)).主要使用的命令是git rebase 或者g ...

  4. [Tensorflow] Practice - The Tensorflow Way

    该系列主要是<Tensorflow 实战Google深度学习框架 >阅读笔记:有了Cookbook的热身后,以这本书作为基础形成个人知识体系. Ref: [Tensorflow] Cook ...

  5. rabbitmq 强制删除集群相关信息,恢复原始状态

    一.前言 同事搭的rabbitmq集群,其中一台一直报下面这种异常:  Error: {inconsistent_cluster,"Node rabbit@mq1 thinks it's c ...

  6. python nose测试框架全面介绍十---用例的跳过

    又来写nose了,这次主要介绍nose中的用例跳过应用,之前也有介绍,见python nose测试框架全面介绍四,但介绍的不详细.下面详细解析下 nose自带的SkipTest 先看看nose自带的S ...

  7. Solr7.4.0的API(Solrj)操作及项目中的使用

    一.SolrJ的概念 solr单机版服务搭建:https://www.cnblogs.com/frankdeng/p/9615253.html solr集群版服务搭建:https://www.cnbl ...

  8. jexus手动跨域设置

    AP.NET MVC默认跨域方法如下: <system.webServer> <validation validateIntegratedModeConfiguration=&quo ...

  9. 熟悉ROS系统中的话题

    描述:这篇教程主要讲解ROS系统中的话题及rostopic和rqt_plot等命令工具: 1. Setup安装1.1 roscore 首先确保roscore已经启动运行,打开一个新的命令终端,输入如下 ...

  10. POJ 1179 - Polygon - [区间DP]

    题目链接:http://poj.org/problem?id=1179 Time Limit: 1000MS Memory Limit: 10000K Description Polygon is a ...