HarmonyOS SideBarContainer可以通过外部进行控制打开和关闭吗?

HarmonyOS
2024-12-24 16:40:47
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
Excelsior_abit

showControlButton设置默认按钮是否显示,showSideBar控制显隐。

参考代码:

// xxx.ets
@Entry
@Component
struct SideBarContainerExample {
  @State show:boolean = false
  build() {
    SideBarContainer(SideBarContainerType.Embed) {
      Column() {
      }.width('100%')
      .justifyContent(FlexAlign.SpaceEvenly)
      .backgroundColor('#19000000')
      Column() {
        Text('点击切换').fontSize(25)
          .onClick(()=>{
            this.show = !this.show
          })
      }
      .margin({ top: 50, left: 20, right: 30 })
    }
    .showSideBar(this.show)
    .showControlButton(false)
    .sideBarWidth(150)
    .minSideBarWidth(50)
    .maxSideBarWidth(300)
    .minContentWidth(0)
    .onChange((value: boolean) => {
      console.info('status:' + value)
    })
    .divider({ strokeWidth: '1vp', color: Color.Gray, startMargin: '4vp', endMargin: '4vp' })
  }
}
分享
微博
QQ
微信
回复
2024-12-24 18:52:29
相关问题
HarmonyOS如何控制打开关闭手电筒
685浏览 • 1回复 待解决
HarmonyOS如何打开外部地图应用
695浏览 • 1回复 待解决
Harmony弹窗可以精确控制位置
1975浏览 • 1回复 待解决
HarmonyOS外部用scheme方法打开app
650浏览 • 1回复 待解决
HarmonyOS 可以在APP中打开手电筒
355浏览 • 1回复 待解决
HarmonyOS SideBarContainer使用问题
189浏览 • 1回复 待解决
HarmonyOS SideBarContainer 转场动画
41浏览 • 1回复 待解决
【ets】switch开关打开后会自动关闭
3637浏览 • 1回复 待解决
HarmonyOS 如何控制软键盘打开、收起?
1143浏览 • 1回复 待解决