React-native-swiper method for setting the height (setting the height of the RN carousel image)

Source: Internet
Author: User

:

Solution:

1. layer view on the swiper label coat

 <View style = {styles. Container}> <Swiper style = {styles. wrapper} Height = {width * 40/75} autoplaytimeout = {2.5} // showbuttons -- whether to display the Left and Right paging buttons showsbuttons = {false} // autoplay -- whether to play autoplay = {true} // paginationstyle -- the style of the container that contains the dot, it is used to adjust the position paginationstyle = {styles. paginationstyle} // dotstyle -- dot style dotstyle = {styles. dotstyle} // activedotstyle -- activedotstyle = {styles. activedotstyle }> <Image Source = {require ('.. /img/mainswiper/swiper1.jpg ')} style = {styles. bannerimg}/> <Image Source = {require ('.. /img/mainswiper/swiper2.jpg ')} style = {styles. bannerimg}/> <Image Source = {require ('.. /img/mainswiper/swiper3.jpg ')} style = {styles. bannerimg}/> </swiper></View> 

2. Set the height in the view style.

 Const Styles = Stylesheet. Create ({Container: {backgroundcolor:  "# F3f3f3", height: width * 40/75  ,},Bannerimg: {Height: width * 40 / 75 , Width: width ,}, wrapper: {width: width ,}, paginationstyle :{}, dotstyle: {width:  22  , Height:  3  , Backgroundcolor:  '  # Fff  '  , Opacity:  0.4  , Borderradius:  0  ,}, Activedotstyle: {width:  22 , Height:  3  , Backgroundcolor:  '  # Fff  '  , Borderradius:  0  ,},}); 

 

3. Do not use flex in the style.

 

4. The full version of the carousel Image Code (the following is the code content of mainswiper. JS)

Import react, {component} from 'react 'import swiper from 'react-native-swiper'; import {image, view, stylesheet,Dimensions, } From 'react-native '; Let {width} = dimensions. Get ('window '); Class mainswiper extends component {render () {return ( <View style = {styles. Container}> <Swiper style = {styles. wrapper} Height = {width * 40/75} autoplaytimeout = {2.5} // showbuttons -- whether to display the Left and Right paging buttons showsbuttons = {false} // autoplay -- whether to play autoplay = {true} // paginationstyle -- the style of the container that contains the dot, it is used to adjust the position paginationstyle = {styles. paginationstyle} // dotstyle -- dot style dotstyle = {styles. dotstyle} // activedotstyle -- activedotstyle = {styles. activedotstyle }> <Image Source = {require ('.. /img/mainswiper/swiper1.jpg ')} style = {styles. bannerimg}/> <Image Source = {require ('.. /img/mainswiper/swiper2.jpg ')} style = {styles. bannerimg}/> <Image Source = {require ('.. /img/mainswiper/swiper3.jpg ')} style = {styles. bannerimg}/> </swiper></View> ) }} Const styles = stylesheet. Create ({ Container: {backgroundcolor: "# f3f3f3", height: width * 40/75 ,}, Bannerimg: {Height: width * 40/75, width: width,}, wrapper: {width: width,}, paginationstyle: {}, dotstyle: {width: 22, height: 3, backgroundcolor: '# fff', opacity: 0.4, borderradius: 0,}, activedotstyle: {width: 22, height: 3, backgroundcolor:' # fff', borderradius: 0 ,},}); export default mainswiper;

React-native-swiper method for setting the height (setting the height of the RN carousel image)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.