当前位置:网站首页>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%')
}
}

总结
边栏推荐
- 有限状态机FSM
- (latest version) WiFi distribution multi format + installation framework
- 【数据库原理及应用教程(第4版|微课版)陈志泊】【第七章习题】
- 01 three solutions to knapsack problem (greedy dynamic programming branch gauge)
- Airflow installation jump pit
- Enter the length of three sides of the triangle through the user, and calculate the area of the triangle, where the length is a real number
- Xctf mobile--app3 problem solving
- 【数据库原理复习题】
- SSH登录服务器发送提醒
- Summary of error prone knowledge points: Calculation of define s (x) 3*x*x+1.
猜你喜欢

【计网】第三章 数据链路层(2)流量控制与可靠传输、停止等待协议、后退N帧协议(GBN)、选择重传协议(SR)

Solve the problem of VI opening files with ^m at the end

高效能人士的七个习惯

Application of ncnn neural network computing framework in orange school orangepi 3 lts development board

(最新版) Wifi分销多开版+安装框架

Powerful avatar making artifact wechat applet

Harmonic current detection based on synchronous coordinate transformation

并网-低电压穿越与孤岛并存分析

ncnn神經網絡計算框架在香柳丁派OrangePi 3 LTS開發板中的使用介紹
![[combinatorics] permutation and combination (the combination number of multiple sets | the repetition of all elements is greater than the combination number | the derivation of the combination number](/img/9d/6118b699c0d90810638f9b08d4f80a.jpg)
[combinatorics] permutation and combination (the combination number of multiple sets | the repetition of all elements is greater than the combination number | the derivation of the combination number
随机推荐
Social community forum app ultra-high appearance UI interface
T430 toss and install OS majave 10.14
高效能人士的七个习惯
Grid connection - Analysis of low voltage ride through and island coexistence
01 three solutions to knapsack problem (greedy dynamic programming branch gauge)
【综合题】【数据库原理】
【ArcGIS自定义脚本工具】矢量文件生成扩大矩形面要素
【数据库原理及应用教程(第4版|微课版)陈志泊】【第四章习题】
ncnn神经网络计算框架在香橙派OrangePi 3 LTS开发板中的使用介绍
[data mining review questions]
【判断题】【简答题】【数据库原理】
Sword finger offer14 the easiest way to cut rope
studio All flavors must now belong to a named flavor dimension. Learn more
Xctf mobile--app2 problem solving
启用MemCached的SASL认证
The solution to change the USB flash disk into a space of only 2m
I'm too lazy to write more than one character
[review questions of database principles]
Pytext training times error: typeerror:__ init__ () got an unexpected keyword argument 'serialized_ options'
C graphical tutorial (Fourth Edition)_ Chapter 15 interface: interfacesamplep268