想要实现一个宽度充满屏幕的dialog弹窗,应该怎么实现?

想要实现一个宽度充满屏幕的dialog弹窗,应该怎么实现,文档上没找到相应属性。

HarmonyOS
2024-10-11 10:26:32
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
put_get

全局弹窗示例代码:

//1.全局开启沉浸式模式  
let windowClass: window.Window = windowStage.getMainWindowSync(); // 获取应用主窗口  
let isLayoutFullScreen = true;  
try {  
  let promise = windowClass.setWindowLayoutFullScreen(isLayoutFullScreen);  
  promise.then(() => {  
    console.info('Succeeded in setting the window layout to full-screen mode.');  
  }).catch((err: BusinessError) => {  
    console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));  
  });  
} catch (exception) {  
  console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception));  
}  
  
//2.自定义弹窗  
@CustomDialog  
export struct CustomerDialog {  
  controller: CustomDialogController  
  
  build() {  
    Column() {  
      Text("提示")  
      Row() {  
        Button('取消', {  
          type: ButtonType.Normal  
        })  
          .width(100)  
          .height(30)  
          .attributeModifier(new TextBodyModifier())  
          .onClick(() => {  
  
          })  
          .fontColor(0x666666)  
          .borderRadius({  
            bottomLeft: 8,  
            bottomRight: 8  
          })  
        Button('确定', {  
          type: ButtonType.Normal  
        })  
          .width(100)  
          .height(30)  
          .attributeModifier(new TextBodyModifier())  
          .onClick(() => {  
          })  
          .fontColor(0x333333)  
          .borderRadius({  
            bottomLeft: 8,  
            bottomRight: 8  
          })  
      }.justifyContent(FlexAlign.SpaceAround)  
    }  
    .width(280)  
    .height(280)  
    .borderRadius(8)  
    .backgroundColor(Color.White)  
    .alignItems(HorizontalAlign.Center)  
    .justifyContent(FlexAlign.SpaceEvenly)  
  }  
}  
private controller: CustomDialogController = new CustomDialogController({  
  builder: CustomerDialog({  
  }),  
  alignment: DialogAlignment.Center,  
  autoCancel: false,  
  customStyle: true,  
  cancel: () => {  
    router.back()  
  }
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
分享
微博
QQ
微信
回复
2024-10-11 16:39:31
相关问题
如何在全局实现一个自定义dialog弹窗
3699浏览 • 1回复 待解决
想要实现一个图片裁剪功能
1250浏览 • 1回复 待解决
如何实现一个带动画弹窗
1321浏览 • 1回复 待解决
ArkTS如何实现一个底部弹窗
1849浏览 • 1回复 待解决
如何实现一个验证码弹窗子窗口
1221浏览 • 1回复 待解决
一个页面怎么实现多个AbilitySlice?
15388浏览 • 5回复 待解决
HarmonyOS swiper手写一个惯性怎么实现
809浏览 • 1回复 待解决
实现一个虚线边框组件。
1489浏览 • 1回复 待解决
我想用XML布局增加一个图片怎么实现
11951浏览 • 4回复 待解决
HarmonyOS 屏幕宽度怎么获取
1026浏览 • 1回复 待解决