传统互动卡片的“破窗”效果是短时的——仅在用户点击触发动效时进入激活态,动效结束后自动恢复为非激活态。
若要实现长期破窗(如自定义边框、卡片边缘悬浮感),可借助背板透明卡片间接达成。具体步骤如下:
{
"forms": [
{
"name": "widget",
"displayName": "$string:widget_display_name",
"description": "$string:widget_desc",
"src": "./ets/widget/pages/WidgetCard.ets",
"uiSyntax": "arkts",
"window": {
"designWidth": 720,
"autoDesignWidth": true
},
"colorMode": "auto",
"isDynamic": true,
"isDefault": true,
"updateEnabled": false,
"scheduledUpdateTime": "10:30",
"updateDuration": 1,
"defaultDimension": "2*2",
"transparencyEnabled": true,
"supportDimensions": [
"2*2"
]
}
]
} @Entry
@Component
struct WidgetCard {
@Builder
item() {
Row()
.backgroundColor(Color.Pink)
.borderRadius(5)
.width(10)
.height(30);
}
build() {
Stack({ alignContent: Alignment.Top }) {
Column() {
Row() {
}
.layoutWeight(1);
Row() {
Text('好好学习 天天向上')
.fontSize(26);
}
.justifyContent(FlexAlign.Center)
.padding(10)
.borderRadius(16)
.backgroundColor(Color.Brown)
.width('100%')
.height('90%');
}.width('100%')
.height('100%');
Row({ space: 10 }) {
this.item();
this.item();
this.item();
}
.justifyContent(FlexAlign.SpaceBetween)
.padding(20)
.width('100%')
.height(30);
};
}
}