android - React Native Image resizeMode='contain' 扭曲了 Android 设备和模拟器上的一些图像
问题描述
resizeMode='contain'
React Native 组件中的扭曲Image
了 Android 设备和模拟器上的一些图像。对于大多数图像,它会在 PNG 图像背景中创建一条扭曲的线条。我尝试了许多不同的图像,也尝试了调整它们的大小,但没有修复扭曲的彩色线条。注意:所有这些图像在 iOS 上看起来都很好。
这是我的Image
组件代码。我正在尝试为比萨应用程序创建图像的网格视图。
<View style={{
flex: 1,
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'stretch',
}}>
{/* ==================================First Row ===================================*/}
<View style={{ height: 600, flexDirection: 'row', backgroundColor: 'transparent', marginVertical: 10 }}>
<View style={{
flex: 1, flexDirection: 'column', marginHorizontal: 20,
borderWidth: 2, borderColor: 'lightgray', borderRadius: 10
}}>
<Image
style={{
flex: 1, height: undefined, width: undefined, borderColor: 'black', borderWidth: 1,
}}
source={require('./Images/pizza5.png')}
resizeMode='contain'>
</Image>
<Text style={{ fontSize: 20, marginVertical: 5, marginHorizontal: 10 }}>Pizza 1</Text>
<Text style={{ fontSize: 17, marginTop: 15, marginBottom: 10, marginHorizontal: 10 }}>$10.99</Text>
</View>
<View style={{
flex: 1, flexDirection: 'column', backgroundColor: 'transparent',
borderWidth: 2, borderColor: 'lightgray', borderRadius: 10, marginRight: 20,
}}>
<Image
style={{
flex: 1, height: undefined, width: undefined, borderColor: 'black', borderWidth: 1
}}
source={require('./Images/pizza1copy.png')}
resizeMode='contain'>
</Image>
<Text style={{ fontSize: 20, marginVertical: 5, marginHorizontal: 10 }}>Pizza 2</Text>
<Text style={{ fontSize: 17, marginTop: 15, marginBottom: 10, marginHorizontal: 10 }}>$10.99</Text>
</View>
</View>
</View>
解决方案
尝试删除borderColor: 'black', borderWidth: 1
并将它们设置为其他父级View
推荐阅读
- swift - Can somebody explain memory allocation for constant defined in struct vs enum?
- php - Problem with dynamic URL rewrite with .htaccess
- android - 缓慢加载水平进度条
- python - 从 to_timedelta 计算年龄很奇怪,并且 DateOffset 在系列上不可扩展
- java - 使用 GPars 时 eachParallel() 抛出 groovy.lang.MissingMethodException
- css - 为什么样式组件中的 flex-value 没有更新?
- java - Apache Ignite:无法从包含过期策略的基本 XML 配置开始
- oracle - 如何处理消息驱动 Bean 中的连接错误?
- django - Django:Q 对象连接
- javascript - 从 json 响应创建列表菜单