reactxp - 如何在 reactXP 中将图像高度和宽度设置为 100%
问题描述
我有一个背景图像,我想将高度和宽度设置为 100%。在 ReactXP 中进行的最佳方式是什么。
解决方案
尝试这个
<View style={{ width: 200, height: 300, backgroundColor: "red" }}>
<Image
source="https://via.placeholder.com/150"
style={{ width: "100%", height: "100%" }}
resizeMode="cover"
/>
</View>
仅在 Web 上测试。如果它在 React Native 上不起作用,则必须测量包装 ViewonLayout
以获取其宽度和高度。
推荐阅读
- kubernetes - Minikube:kubectl 不使用提供的令牌权限
- sql-server - T-SQL sp_xml_preparedocument 创建空表
- swift - 使用结构而不是类的简单 SwiftUI CRUD?
- cron - 如何在 cron 中使用空格?
- c++ - 离散分布返回整数越界
- coldfusion - 在我的示例中如何正确组织 Coldfusion 中的线程工作
- sql - 无法从标量/JSONB 中提取数据
- reactjs - 如何让 ESLint 从根目录扫描所有文件(递归)?
- java - 当我尝试发送某些东西时,TCP 连接将中止,
- javascript - 如何在 ElectronJS 中设置窗口名称/标题?