如何固定半模态转场的高度

如何固定半模态转场的高度

HarmonyOS
2024-07-24 10:52:23
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
roseprodigal

在使用`bindSheet`函数时,可以通过`options?: SheetOptions`参数对表格的高度进行精细化调整,以满足特定的显示需求。然而,需要明确的是,该函数当前并不支持直接控制表格的固定宽度。

参考代码如下:

@Entry
@Component
struct SheetTransitionExample {
  @State isShow: boolean = false;
  @State sheetHeight: number = 300;

  @Builder
  myBuilder() {
    Column() {
      Button('change height')
        .margin(10)
        .fontSize(20)
        .onClick(() => {
          this.sheetHeight = 500;
        })

      Button('Set Illegal height')
        .margin(10)
        .fontSize(20)
        .onClick(() => {
          this.sheetHeight = 0;
        })
    }
    .width('100%')
    .height('100%')
  }

  build() {
    Column() {
      Button('transition modal 1')
        .onClick(() => {
          this.isShow = true;
        })
        .fontSize(20)
        .margin(10)
        .bindSheet(this.isShow, this.myBuilder(), { height: this.sheetHeight, backgroundColor: Color.Green })
    }
    .justifyContent(FlexAlign.Center)
    .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.
分享
微博
QQ
微信
回复
2024-07-24 19:51:15


相关问题
模态转场如何控制固定高度
2383浏览 • 1回复 待解决
HarmonyOS 模态转场
657浏览 • 1回复 待解决
HarmonyOS 关于模态转场疑问
574浏览 • 1回复 待解决
模态转场来实现弹框样式页面
1390浏览 • 1回复 待解决
HarmonyOS 如何转换模态
607浏览 • 1回复 待解决