当前位置:网站首页>OpenHarmony应用开发之ETS开发方式中的Image组件
OpenHarmony应用开发之ETS开发方式中的Image组件
2022-07-03 12:13:00 【InfoQ】
Image
(src: string | PixelMap | Resource): ImageAttribute;
引用App本地图片
@Entry
@Component
struct Index {
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text("media目录下的媒体资源").fontSize(32).fontColor(Color.Orange)
Image($r("app.media.HarmonyOS")) // media目录下的媒体资源
.width("100%")
.aspectRatio(1.5)
Text("/common/images目录下的图片").fontSize(32).fontColor(Color.Orange).textAlign(TextAlign.Center)
Image("/common/images/HarmonyOS.jpg") // /common/images目录下的图片
.width("100%")
.aspectRatio(1.5)
}
.width('100%')
}
.height('100%')
}
}

引用网络图片时记得添加权限
"abilities": [
{
...
"permissions": ["ohos.permission.INTERNET"],
...
}
]
@Entry
@Component
struct Index {
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text("media目录下的媒体资源").fontSize(32).fontColor(Color.Orange)
Image($r("app.media.HarmonyOS")) // media目录下的媒体资源
.width("100%")
.aspectRatio(2.6)
Text("/common/images目录下的图片").fontSize(32).fontColor(Color.Orange).textAlign(TextAlign.Center)
Image("/common/images/HarmonyOS.jpg") // /common/images目录下的图片
.width("100%")
.aspectRatio(2.6)
Text("网络图片,jpg格式").fontSize(32).fontColor(Color.Orange).textAlign(TextAlign.Center)
Image("https://img95.699pic.com/photo/50080/9588.jpg_wh300.jpg") // /common/images目录下的图片
.width("100%")
.aspectRatio(2.6)
}
.width('100%')
}
.height('100%')
}
}

总结
边栏推荐
- Node. Js: use of express + MySQL
- C graphical tutorial (Fourth Edition)_ Chapter 20 asynchronous programming: examples - using asynchronous
- [combinatorics] permutation and combination (multiple set permutation | multiple set full permutation | multiple set incomplete permutation all elements have a repetition greater than the permutation
- How to get user location in wechat applet?
- Record your vulnhub breakthrough record
- Summary of error prone knowledge points: Calculation of define s (x) 3*x*x+1.
- 基于同步坐标变换的谐波电流检测
- 2021 autumn Information Security Experiment 1 (password and hiding technology)
- Bert running error: attributeerror: module'tensorflow contrib. tpu' has no attribute 'InputPipelineConfig'
- 十条职场规则
猜你喜欢
Grid connection - Analysis of low voltage ride through and island coexistence
Integer case study of packaging
Drop down refresh conflicts with recyclerview sliding (swiperefreshlayout conflicts with recyclerview sliding)
我的创作纪念日:五周年
The latest version of blind box mall thinkphp+uniapp
01 three solutions to knapsack problem (greedy dynamic programming branch gauge)
(latest version) WiFi distribution multi format + installation framework
Low code platform international multilingual (I18N) technical solution
【数据挖掘复习题】
Analysis of a music player Login Protocol
随机推荐
【数据库原理及应用教程(第4版|微课版)陈志泊】【SQLServer2012综合练习】
【计网】第三章 数据链路层(2)流量控制与可靠传输、停止等待协议、后退N帧协议(GBN)、选择重传协议(SR)
ImportError: No module named examples. tutorials. mnist
The latest version of lottery blind box operation version
Express abstract classes and methods
CVPR 2022 图像恢复论文
Airflow installation jump pit
Keep learning swift
Pytext training times error: typeerror:__ init__ () got an unexpected keyword argument 'serialized_ options'
【判断题】【简答题】【数据库原理】
C graphical tutorial (Fourth Edition)_ Chapter 13 entrustment: what is entrustment? P238
Tensorflow binary installation & Failure
Everything comes to him who waits
【習題七】【數據庫原理】
Xctf mobile--app2 problem solving
(latest version) WiFi distribution multi format + installation framework
Two solutions of leetcode101 symmetric binary tree (recursion and iteration)
Xctf mobile--app3 problem solving
C graphical tutorial (Fourth Edition)_ Chapter 15 interface: interfacesamplep271
Harmonic current detection based on synchronous coordinate transformation