react-native - 反应原生绝对定位使图像裁剪
问题描述
我在将图像放置在容器内时遇到问题,那就是当我给图像position: absolute
和top
属性图像从顶部裁剪时,这是问题所在:
这是我的代码:
<View style={styles.OurTherapistsContainer}>
<View style={styles.therapistCard}>
<View style={styles.imageContainer}>
<Image style={styles.image} source={require('../assets/img/leong.png')} />
</View>
</View>
</View>
...
therapistCard: {
width: 150,
height: 150,
borderRadius: 25,
borderWidth: 1,
borderColor: '#DFEEFF',
overflow: 'hidden',
},
imageContainer: {
width: 150,
height: 150,
backgroundColor: 'red',
},
image: {
width: '100%',
height: '100%',
position: "absolute",
top: 30
}
我怎样才能解决这个问题?
解决方案
尝试在图像样式中使用 resizeMode
resizeMode:'contain'
推荐阅读
- javascript - 使用 javascript 确认时,Asp.net requiredfieldvalidator 停止工作
- html - 缩放和变换原点后网页没有覆盖整个屏幕高度
- arrays - 如何检查我的 Object PersistantCollection 中是否存在值?
- angular - 角度:为什么值更改(使用渲染器2)不会触发绑定到该的事件
- typescript - 共享自定义 NestJS 模块给出“不是当前处理模块的一部分”错误
- python - 子类未在 Python 2.x 中初始化父类
- python - 直方图给出了概率密度函数的奇怪值
- java - 如何在日志文本上将 OrderId 显示为 Log4j 模式布局
- android - 改造 - 处理刷新令牌过期
- ios - 更改语义内容属性后 UI 挂起