【发布时间】:2017-06-15 02:23:18
【问题描述】:
我想像这样连续获取带有图片和标题的标题: Desired result
使用此代码:
<View style={{ flex: 1, backgroundColor:'#ccf6c0', flexDirection:'column',}}>
{/* ======================= HEADER ===================================*/}
<View style={{flex: 0, flexDirection: 'row', backgroundColor:'#d5d5f7'}}>
<Image
source={require('./images/logo.png')}
style={{resizeMode: 'contain', flex: 1}}
/>
<View style={{flex: 1, justifyContent: 'center', backgroundColor:'#f7d5d5'}}>
<Text style={{fontSize: 17, fontWeight:'bold', marginLeft: 7}}>
Title
</Text>
</View>
</View>
</View>
但是我得到了这个输出:Wrong result - 图像上方和下方有不必要的空间。
为了得到想要的结果,我在这里缺少什么?
我的猜测:图像的原始大小为 360x180(因此默认情况下它应该是 768 模拟器屏幕的一半宽度),但 Android 接受它作为 mdpi 图像并放大到 xhdpi(两个方向 x2),然后使用它放大图像以计算容器高度。只有 THEN resizeMode: 'contain' 适用(在新的双高容器内)。 有什么建议?
【问题讨论】:
标签: image react-native resize flexbox