css - 为什么我的反应原生项目中没有应用背景图像
解决方案
用 View 包裹你的 imageBackground:
<View style={styles.imgWrap}>
<ImageBackground
source={require('assets/img/avatar-placeholder.png')}
style={styles.img}
/>
</View>
然后添加一些样式:
const styles = StyleSheet.create({
imgWrap: {
width: 100,
height: 100,
overflow: 'hidden',
borderRadius: 50,
},
img: {
flex: 1,
resizeMode: "contain",
justifyContent: "center"
}
})
推荐阅读
- php - 如何修复 Laravel 中未定义的变量错误?
- flutter - 为什么 Dart 不能定义依赖于另一个实例属性的实例属性
- weblogic12c - Weblogic Server 在会话 ID 生成期间包含 NONE 值
- python - 如何使用 pip 安装 gspread?
- xslt - Xpath3 表达式或 XSLT 代码以获取具有特定属性的所有节点名称,以便它们出现
- python - Pygame 如何制作斜坡?
- java - 如何使用 Camel Jms 事务回滚回滚 OracleDB 提交
- excel - Excel VBA || 在过滤范围内填充值
- f# - 如何在 Elmish.WPF 中完成子/子模型到父/主模型的消息传递?
- r - R:如何在特定列上删除包含小于 -4 和大于 4 的任何值的行?