我试图在滚动视图中显示图像列表。宽度应该是100% ,而高度应该是自动的,保持长宽比。
我所做的搜索指向各种解决方案,提供全屏幕背景风格。
const styles = StyleSheet.create({
image: {
width: null,
height: 300,
resizeMode: 'cover'
}
});
<ScrollView style={{flex: 1}}>
<Image style={styles.image} source={require('../../../images/collection-imag1.png')}/>
<Image style={styles.image} source={require('../../../images/collection-imag2.png')}/>
</ScrollView>
我尝试了各种宽度组合: null、 height: null、 flex: 1、 alignSelf 等。除了高度不是动态的以外,上面的解决方案几乎可以正常工作。图像的某些部分不可见。