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如何控制打开关闭手电筒
1791浏览 • 1回复 待解决
HarmonyOS如何打开外部地图应用
1537浏览 • 1回复 待解决
Harmony弹窗可以精确控制位置
2723浏览 • 1回复 待解决
HarmonyOS外部用scheme方法打开app
1386浏览 • 1回复 待解决
HarmonyOS 可以在APP中打开手电筒
1194浏览 • 1回复 待解决
HarmonyOS SideBarContainer使用问题
932浏览 • 1回复 待解决
HarmonyOS SideBarContainer 转场动画
894浏览 • 1回复 待解决
【ets】switch开关打开后会自动关闭
4895浏览 • 1回复 待解决
HarmonyOS 应用内如何主动打开/关闭 wifi
1106浏览 • 1回复 待解决
鸿蒙动态页面的摄像头可以打开
681浏览 • 0回复 待解决