javascript - React Native flexible view sizing within a paged scrollview -


i'm trying use scrollview (with paging enabled) in react native page through series of images. know how make image views fill each page of scroll view? far i've had luck hard coding width , height values image style.

here's i'm doing:

render: function() {   return (     var images = [{ url: 'http://url/to/image.jpg' }, { url: 'http://url/to/another-image.jpg'}];     <scrollview horizontal={true} pagingenabled={true} style={styles.myscrollviewstyle}>       {images.map(image => {         return (           <image source={{uri: image.url}} style={styles.myimagestyle} />         );       })}     </scrollview>   ); } 

the way images show if hardcode width/height number in style. i've been unable image flex fill 1 whole page.

scrollview style:

scrollview: {   flex: 1,   backgroundcolor: '#000000', } 

image style:

image: {   width:375,   height:667,   flex: 1,   backgroundcolor: 'rgba(0,0,0,0)', } 

to set image dimensions use next code:

var dimensions = require('dimensions'); var windowsize = dimensions.get('window'); 

...

image: {   width: windowsize.width,   height: windowsize.height,   flex: 1,   backgroundcolor: 'rgba(0,0,0,0)', } 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -