如何写精华回答,获更多曝光?
发布
在开发中需要实现一个浮窗,通过以下代码创建的子窗口设置背景颜色不生效。
let mainWindow: window.WindowStage = AppStorage.get(CommonConstants.MAIN_WINDOW) as window.WindowStage;
mainWindow.createSubWindow(CommonConstants.VOICE_BROADCAST_SUB_WINDOW, (err, subWindow) => {
if (err.code > 0) {
Logger.error(TAG, 'Failed to create subWindow. Cause: ' + JSON.stringify(err));
return;
}
try {
subWindow.loadContent('news/pages/VoiceBroadcastSubWindow', storage, (err: BusinessError) => {
const errCode: number = err.code;
if (errCode) {
Logger.error(TAG, `Failed to load the content. Cause code: ${err.code}, message: ${err.message}`);
return;
}
console.info('Succeeded in loading the content.');
});
// 设置子窗口左上角坐标
subWindow.moveWindowTo(vp2px(5), vp2px(700));
// 设置子窗口大小
subWindow.resize(vp2px(220), vp2px(40));
// 展示子窗口
subWindow.showWindow();
subWindow.setWindowBackgroundColor('#00000000')
} catch (err) {
Logger.error(TAG, `failed to create subWindow Cause: ${err.code}, message: ${err.message}`);
}
})
调用subWindow.setWindowBackgroundColor('#00000000')后窗口背景颜色仍为白色。因为浮窗要设置为圆角,所以必须背景颜色为透明,请问要如何设置?