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

总结
边栏推荐
- 最新版抽奖盲盒运营版
- Solve the problem of VI opening files with ^m at the end
- 关于CPU缓冲行的理解
- Using swift language features, write a pseudo-random number generator casually
- C graphical tutorial (Fourth Edition)_ Chapter 20 asynchronous programming: examples - cases without asynchronous
- Comprehensive evaluation of double chain notes · Siyuan notes: advantages, disadvantages and evaluation
- Dojo tutorials:getting started with deferrals source code and example execution summary
- Harmonic current detection based on synchronous coordinate transformation
- Kung Fu pays off, and learning is done
- Public and private account sending prompt information (user microservice -- message microservice)
猜你喜欢
![[ArcGIS user defined script tool] vector file generates expanded rectangular face elements](/img/39/0b31290798077cb8c355fbd058e4d3.png)
[ArcGIS user defined script tool] vector file generates expanded rectangular face elements

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?

Idea packages the web project into a war package and deploys it to the server to run
![[review questions of database principles]](/img/c3/81d192a40bcc4f5d72fcbe76c708bb.png)
[review questions of database principles]

Leetcode234 palindrome linked list

最新版抽奖盲盒运营版

4. 无线体内纳米网:电磁传播模型和传感器部署要点

【数据库原理及应用教程(第4版|微课版)陈志泊】【第四章习题】

Glide question you cannot start a load for a destroyed activity

GaN图腾柱无桥 Boost PFC(单相)七-PFC占空比前馈
随机推荐
ncnn神经网络计算框架在香橙派OrangePi 3 LTS开发板中的使用介绍
A large select drop-down box, village in Chaoyang District
[exercise 6] [Database Principle]
Xctf mobile--app1 problem solving
阿里 & 蚂蚁自研 IDE
Leetcode234 palindrome linked list
Project video based on Linu development
对业务的一些思考
Enable SASL authentication for memcached
Quickly learn member inner classes and local inner classes
低代码平台国际化多语言(i18n)技术方案
Swift Error Handling
C graphical tutorial (Fourth Edition)_ Chapter 18 enumerator and iterator: enumerator samplep340
Kung Fu pays off, and learning is done
[exercice 7] [principe de la base de données]
C graphical tutorial (Fourth Edition)_ Chapter 13 entrustment: delegatesamplep245
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?
Export the entire Oracle Database
[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
Simple use and precautions of kotlin's array array and set list