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

总结
边栏推荐
- 01 three solutions to knapsack problem (greedy dynamic programming branch gauge)
- 强大的头像制作神器微信小程序
- 【数据库原理及应用教程(第4版|微课版)陈志泊】【第三章习题】
- Nodejs+Express+MySQL实现登陆功能(含验证码)
- 【判断题】【简答题】【数据库原理】
- When the R language output rmarkdown is in other formats (such as PDF), an error is reported, latex failed to compile stocks Tex. solution
- Kotlin - 改良装饰者模式
- 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
- Redhat5 installing socket5 proxy server
- C graphical tutorial (Fourth Edition)_ Chapter 17 generic: genericsamplep315
猜你喜欢

Application of ncnn Neural Network Computing Framework in Orange Pi 3 Lts Development Board

(latest version) WiFi distribution multi format + installation framework

2021 autumn Information Security Experiment 1 (password and hiding technology)

Differences between initial, inherit, unset, revert and all

Analysis of the influence of voltage loop on PFC system performance

How to convert a decimal number to binary in swift

Day 1 of kotlin learning: simple built-in types of kotlin

Social community forum app ultra-high appearance UI interface

Brief introduction to mvcc

并网-低电压穿越与孤岛并存分析
随机推荐
[exercise 5] [Database Principle]
[network counting] Chapter 3 data link layer (2) flow control and reliable transmission, stop waiting protocol, backward n frame protocol (GBN), selective retransmission protocol (SR)
Xctf mobile--rememberother problem solving
C graphical tutorial (Fourth Edition)_ Chapter 13 entrustment: delegatesamplep245
Swift5.7 extend some to generic parameters
4. Wireless in vivo nano network: electromagnetic propagation model and key points of sensor deployment
How to stand out quickly when you are new to the workplace?
ncnn神經網絡計算框架在香柳丁派OrangePi 3 LTS開發板中的使用介紹
Ali & ant self developed IDE
How to get user location in wechat applet?
Drop down refresh conflicts with recyclerview sliding (swiperefreshlayout conflicts with recyclerview sliding)
剑指 Offer 11. 旋转数组的最小数字
Detailed explanation of the most complete constraintlayout in history
With pictures and texts, summarize the basic review of C language in detail, so that all kinds of knowledge points are clear at a glance?
The upward and downward transformation of polymorphism
The latest version of blind box mall thinkphp+uniapp
Airflow installation jump pit
studio All flavors must now belong to a named flavor dimension. Learn more
Swift5.7 扩展 some 到泛型参数
并网-低电压穿越与孤岛并存分析