HarmonyOS卡片编辑与背景模糊开发

鸿蒙时代
发布于 2021-9-27 10:28
浏览
0收藏

一.卡片编辑功能
卡片提供方提供一个卡片的编辑页面,允许从卡片跳转至编辑页面。

卡片提供方在配置文件config.json中添加参数“formConfigAbility”,配置参数信息的规则如下。
配置该参数的值,导航到编辑页面的Page ability,格式如下:

ability://单个ability名字

如果不配置“formConfigAbility”参数,则无卡片编辑功能。
二.卡片背景模糊
卡片可以在config.json中声明是否支持背景模糊。声明方式如下:

config.json的metaData中,
在customizeData中增加一个name为needBlurBackgroundForLauncher的字符串类型的属性,value为“true”表示支持, 否则为不支持。
.“forms”: [
.{
.“name”: “Form_JS_DEMO”,
.“description”: “it is js form”,
.“type”: “JS”,
.“jsComponentName”: “card”,
.“colorMode”: “auto”,
.“isDefault”: true,
.“updateEnabled”: true,
.“scheduledUpdateTime”: “10:30”,
.“defaultDimension”: “22",
.“supportDimensions”: [
."2
2”,
.“2*4”
.],
.“metaData”: {
.“customizeData”: [
.{
.“name”: “needBlurBackgroundForLauncher”,
.“value”: “true”
.}
.]
.}
.}
.]

卡片开发者可以从onCreateForm的回调中,获取是否支持背景模糊:

.protected ProviderFormInfo onCreateForm(Intent intent) {

.// 1. 获取自定义数据
.IntentParams intentParams = intent.getParam(AbilitySlice.PARAM_FORM_CUSTOMIZE_KEY);
.
.// 2. 从intentParams中获取是否支持背景模糊
.boolean isSupport = (boolean) intentParams.getParam(“fa_card_background_blur_support”);

.}

说明
背景模糊限制:
当前仅JS卡片支持背景模糊。
卡片背景模糊需要硬件支持,目前支持搭载麒麟9000或高通骁龙865及以上型号CPU的机型。使用其他机型可能无法预览到背景模糊效果。

本文主要根据HarmonyOS官方文档整理。

HarmonyOS卡片编辑与背景模糊开发.docx 16.92K 4次下载
1
收藏
回复
举报
回复
    相关推荐