HarmonyOS CustomDialog底部默认间距

CustomDialog与手机屏幕底部有一段间距,无法设置充满屏幕底部。customStyle为true,内部布局没有下边距。

HarmonyOS
2024-10-15 12:36:40
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
Heiang

初始化自定义弹窗时,通过alignment参数设置对齐方式,通过offset设置弹窗偏移量。参考链接:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-methods-custom-dialog-box-V5#customdialogcontrolleroptions%E5%AF%B9%E8%B1%A1%E8%AF%B4%E6%98%8E

也可以使用半模态或者panel组件来实现,底部没有间距。panel组件可以参考文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-container-panel-V5

半模态参考代码:

@Entry  
@Component  
struct bindsheet {  
  @State isShow: boolean = false  
  @Builder  
  myBuilder() {  
    Column() {  
      Button("关闭弹窗")  
        .margin(10)  
        .fontSize(20)  
        .onClick(() => {  
          this.isShow = false;  
        })//通过点击事件将isShow属性变为false,bindSheet弹窗关闭  
    }  
    .width('100%')  
    .height('100%')  
  }  
  
  build() {  
    Column() {  
      Button("打开弹窗")  
        .onClick(() => {  
          this.isShow = true  
        })  
          //通过点击事件将isShow属性变为true,bindSheet弹窗弹出  
        .fontSize(20)  
        .margin(10)  
        .bindSheet($$this.isShow, this.myBuilder(), {  
          detents: [SheetSize.MEDIUM, SheetSize.LARGE, 200],  
          backgroundColor: Color.Gray,  
          showClose:false, //不显示关闭按钮  
          enableOutsideInteractive: true, //允许交互,不显示蒙层  
          blurStyle: BlurStyle.Thick,  
          preferType: SheetType.CENTER,  
          shouldDismiss: ((sheetDismiss: SheetDismiss) => {  
            console.log("bind sheet shouldDismiss")  
            sheetDismiss.dismiss()  
          })  
        })  
    }  
    .backgroundColor("#ff578ddd")  
    .justifyContent(FlexAlign.Start)  
    .width('100%')  
    .height('100%')  
  }  
}
  • 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.
分享
微博
QQ
微信
回复
2024-10-15 17:30:56


相关问题
HarmonyOS CustomDialog底部space
722浏览 • 1回复 待解决
HarmonyOS List组件默认滚动到最底部
1179浏览 • 1回复 待解决
HarmonyOS Grid间距问题
577浏览 • 1回复 待解决
Span组件设置行间距间距
1281浏览 • 1回复 待解决
HarmonyOS CustomDialog相关
626浏览 • 1回复 待解决
HarmonyOS @CustomDialog 调用 pushUrl
805浏览 • 1回复 待解决
HarmonyOS 关于CustomDialog使用
1091浏览 • 1回复 待解决
HarmonyOS ActionSheet选项间距太小
526浏览 • 1回复 待解决
HarmonyOS CustomDialog中弹AlertDialog问题
875浏览 • 1回复 待解决
HarmonyOS class中显示CustomDialog
661浏览 • 1回复 待解决
HarmonyOS lineSpacing间距设置有问题
787浏览 • 1回复 待解决
HarmonyOS CustomDialog焦点
435浏览 • 1回复 待解决
HarmonyOS CustomDialog显示
489浏览 • 1回复 待解决