From 0573742ddfa74a37689ff6327a173733e21a2624 Mon Sep 17 00:00:00 2001 From: wangyihui Date: Wed, 5 Jul 2023 08:24:54 +0000 Subject: [PATCH] =?UTF-8?q?=E3=80=90Drawable=E3=80=91=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=A4=BA=E4=BE=8B=E4=BB=A3=E7=A0=81=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangyihui Change-Id: Ia98dc6e723755c52c82807b17c7b82294785180f --- .../apis/js-apis-arkui-drawableDescriptor.md | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/zh-cn/application-dev/reference/apis/js-apis-arkui-drawableDescriptor.md b/zh-cn/application-dev/reference/apis/js-apis-arkui-drawableDescriptor.md index 6a7b166b54..e646926dbc 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-arkui-drawableDescriptor.md +++ b/zh-cn/application-dev/reference/apis/js-apis-arkui-drawableDescriptor.md @@ -31,6 +31,18 @@ constructor() 当传入资源id或name为包含前景和背景资源的json文件时,生成LayeredDrawableDescriptor对象。 +drawble.json文件如下: + +```json +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} +``` + **示例:** ```ts // xxx.ets @@ -45,7 +57,7 @@ struct Index { Row() { Column() { Image(( (this.resManager.getDrawableDescriptor($r('app.media.icon').id)))) - Image((( (this.resManager.getDrawableDescriptor($r('app.media.icon') + Image((( (this.resManager.getDrawableDescriptor($r('app.media.drawable') .id))).getForeground()).getPixelMap()) }.height('50%') }.width('50%') @@ -87,8 +99,8 @@ getPixelMap(): image.PixelMap; **示例:** ```ts -pixmap: PixelMap = (( (this.resManager.getDrawableDescriptor($r('app.media.icon') - .id))).getForeground()).getPixelMap(); +pixmap: PixelMap = ( (this.resManager.getDrawableDescriptor($r('app.media.drawable') + .id))).getPixelMap(); ``` ## LayeredDrawableDescriptor.getForeground @@ -106,7 +118,7 @@ getForeground(): DrawableDescriptor; **示例:** ```ts -drawable: DrawableDescriptor = ( (this.resManager.getDrawableDescriptor($r('app.media.icon') +drawable: DrawableDescriptor = ( (this.resManager.getDrawableDescriptor($r('app.media.drawable') .id))).getForeground(); ``` @@ -125,7 +137,7 @@ getBackground(): DrawableDescriptor; **示例:** ```ts -drawable: DrawableDescriptor = ( (this.resManager.getDrawableDescriptor($r('app.media.icon') +drawable: DrawableDescriptor = ( (this.resManager.getDrawableDescriptor($r('app.media.drawable') .id))).getBackground(); ``` @@ -144,6 +156,6 @@ getMask(): DrawableDescriptor; **示例:** ```ts -drawable: DrawableDescriptor = ( (this.resManager.getDrawableDescriptor($r('app.media.icon') +drawable: DrawableDescriptor = ( (this.resManager.getDrawableDescriptor($r('app.media.drawable') .id))).getMask(); ``` -- GitLab