HarmonyOS 如何将page设置为透明

HarmonyOS
2024-12-25 13:12:47
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
put_get

主窗口规格是没有白色背景,也做不到完全透明,会有高斯模糊。可将子窗口背景颜色设置为透明,參考如下:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-window-V5#setwindowbackgroundcolor9

如果要设置类似这种加载进度的LoadingProgress的话,也可以尝试下使用NavDestination,NavDestinationMode属性设置为DIALOG默认透明,参考链接:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-basic-components-navdestination-V5

可以尝试直接在EntryAbility中添加:

onWindowStageCreate(windowStage: window.WindowStage): void {
  // Main window is created, set main page for this abilitydata.setWindowBackgroundColor('#00ff33')
  hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
  AppStorage.setAndLink('windowStage', windowStage); // 关键代码
  windowStage.loadContent('pages/Index', (err, data) => {
  if (err.code) {
  hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
  return;
  }
  hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
  windowStage.getMainWindowSync().setWindowBackgroundColor('#00ff33')
  });
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.

也可以在page中:

@Entry
@Component
struct Index {
  @State message: string = 'Hello World';

  build() {
    Stack() {
      Row() {
        Text('我是下面的Row').fontSize(40)
      }.height('80%').width('80%').backgroundColor(Color.Gray)
      Column() {
        Text('我是上面的Column').fontSize(40)
      }.height('60%').width('60%').backgroundColor("#52dd3f3f")
    }.width('100%').height('100%')
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
分享
微博
QQ
微信
回复
2024-12-25 16:14:45
相关问题
如何将背景颜色设置透明
3604浏览 • 1回复 待解决
HarmonyOS 页面如何将背景处理透明
809浏览 • 1回复 待解决
HarmonyOS page和WebView无法设置透明
1220浏览 • 1回复 待解决
HarmonyOS List组如何将背景色设置透明
520浏览 • 1回复 待解决
如何将Ability的UI界面设置透明
2640浏览 • 1回复 待解决
如何将页面设置深色模式
3012浏览 • 1回复 待解决
HarmonyOS 如何page页面设置透明
1504浏览 • 1回复 待解决
如何设置卡片背景透明
3655浏览 • 1回复 待解决
HarmonyOS page页面如何设置透明效果
717浏览 • 1回复 待解决
XComponent 怎么设置透明
2873浏览 • 1回复 待解决
设置XComponent组件透明
1215浏览 • 1回复 待解决
如何将har库迁移hsp库
1509浏览 • 1回复 待解决
HarmonyOS page透明
478浏览 • 1回复 待解决
HarmonyOS 可以设置页面透明背景吗?
1024浏览 • 1回复 待解决
Tab 设置 barBackgroundColor透明不生效
762浏览 • 1回复 待解决
page页面如何设置横屏显示
2436浏览 • 1回复 待解决
HarmonyOS 如何实现半透明Page
857浏览 • 1回复 待解决
HarmonyOS page透明
479浏览 • 1回复 待解决