React Native Image doesn't resize on device (iOS) orientation change? -


i'm react native n00b, perhaps i'm missing brutally obvious.

      <image         source={signoutgradient}         resizemode="cover"         style={{ height: 60, justifycontent: 'center', alignitems: 'center', backgroundcolor: 'rgba(0,0,0,0)' }}       >         <button           title="sign out"           color="#ffffff"           onpress={this.onpresssignout}         />       </image> 

... gives me in portrait on ios device (good):

portrait

... in landscape mode (bad) when rotate device. how come? how fix this? expecting size of actual png image file doesn't matter, because should stretched larger if needs be. doesn't seem happening.

landscape

fyi dimensions module doesn't automatically update when screen rotates. option if can somehow detect rotation , force rerender.

one option wrapping components need responsive view , use onlayout property. function passed onlayout receive {nativeevent: { layout: {x, y, width, height}}} containing view's updated position , dimensions time change; if write these component's state can automatically recalculate new height , width , trigger rerender when screen rotates (e.g. set onlayout on root view , update image's width width of entire screen). can ctrl+f "onlayout" here.

the flex style prop updates on rotation, possibly set flex:1 example on root component , somehow use flexbox keep styled responsively.


Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -