promptAction.openCustomDialog创建的自定义弹窗蒙层颜色不支持设置0x00000000为纯透明 HarmonyOS 鸿蒙Next
promptAction.openCustomDialog创建的自定义弹窗蒙层颜色不支持设置0x00000000为纯透明 HarmonyOS 鸿蒙Next
【设备信息】 Mate60pro
【API版本】 Api14
【DevEco Studio版本】 5.0.2 Release
promptAction.openCustomDialog
创建的自定义弹窗不支持设置蒙层颜色为纯透明,使用 0x00000000
时,弹窗背景全部黑色。
使用 Color.Transparent
或者 app 中自定义的 color 值 #00000000
,可以将弹窗蒙层设置为纯透明。说明目前系统在解析 0x00000000
时出现问题,未能当做是纯透明色,而是当做了纯黑色 #FF000000
更多关于promptAction.openCustomDialog创建的自定义弹窗蒙层颜色不支持设置0x00000000为纯透明 HarmonyOS 鸿蒙Next的实战教程也可以访问 https://www.itying.com/category-93-b0.html
参考下面demo,可以设置背景板为透明色:
import { BusinessError } from '@kit.BasicServicesKit';
import { ComponentContent } from '@kit.ArkUI';
class Params {
text: string = "";
constructor(text: string) {
this.text = text;
}
}
@Builder
function buildText(params: Params) {
Column() {
Text(params.text)
.fontSize(50)
.fontWeight(FontWeight.Bold)
.margin({bottom: 36})
}/*.backgroundColor('#FFF0F0F0')*/
}
@Entry
@Component
struct Index {
@State message: string = "hello"
build() {
Row() {
Column() {
Button("click me")
.onClick(() => {
let uiContext = this.getUIContext();
let promptAction = uiContext.getPromptAction();
let contentNode = new ComponentContent(uiContext, wrapBuilder(buildText), new Params(this.message));
try {
promptAction.openCustomDialog(contentNode);
} catch (error) {
let message = (error as BusinessError).message;
let code = (error as BusinessError).code;
console.error(`OpenCustomDialog args error code is ${code}, message is ${message}`);
};
})
}
.width('100%')
.height('100%')
}
.height('100%')
}
}
更多关于promptAction.openCustomDialog创建的自定义弹窗蒙层颜色不支持设置0x00000000为纯透明 HarmonyOS 鸿蒙Next的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
在HarmonyOS鸿蒙Next中,promptAction.openCustomDialog
创建的自定义弹窗蒙层颜色设置为0x00000000
时,无法实现纯透明效果。这是由于系统对蒙层颜色的处理机制限制,0x00000000
被视为无效值,系统会默认使用半透明黑色作为蒙层颜色。要实现透明蒙层,可以使用0x01000000
,这是一个接近透明但有效的颜色值。