This answer is deprecated, use halilb answer.
I solved this using the onLayout , it is very simple:
Example:
Step 1: I create in our state a support that will contain the current height of the image named curImgHeight .
constructor(){ super(props); this.state={curImgHeight:0} }
Step 2: Use the support in any View or Element that supports the onLayout support.
Here I use it with Image . Then all we need to do is change this state property if the actual image height is less than our minimum height.
render(){ <Image source={{uri: "https://placehold.it/350x150"}} resizeMode='cover' style={[styles.image, {height:(this.state.curImgHeight<=0?null:this.state.curImgHeight)}]} onLayout={(e)=>{ let {height} = e.nativeEvent.layout; let minimumImgHeight = 400;
This is how I decided it for me.
ps: during the search, I found that the reactive version informally supports minHeight and maxHeight , but only for iOS, not for Android. I would not dare to use them. The above code works well and gives me control.
SudoPlz May 18 '16 at 19:14 2016-05-18 19:14
source share