#鸿蒙通关秘籍#如何为TabBar中间页实现圆弧外轮廓效果

HarmonyOS
2024-12-06 14:56:55
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
CDN古木参天

为实现TabBar中间页面的圆弧外轮廓效果,可以将Image组件外包一层容器,并通过设置borderRadiusmargintop值来达到效果。borderRadius值设为容器宽度的一半,margintop值根据具体效果进行调整。以下代码展示了具体实现方式:

Column() {
    Image(this.selectedIndex === this.tabBarIndex ? TABINFO[this.tabBarIndex].selectedIcon :
          TABINFO[this.tabBarIndex].defaultIcon)
      .size({
        width: $r('app.integer.custom_tab_community_image_size'),
        height: $r('app.integer.custom_tab_community_image_size')
      })
      .interpolation(ImageInterpolation.High)
  }
  .width($r('app.integer.custom_tab_community_image_container_size'))
  .height($r('app.integer.custom_tab_community_image_container_size'))
  .borderRadius($r('app.integer.custom_tab_community_image_container_border_radius_size'))
  .margin({ top: ARC_MARGIN_TOP })
  .backgroundColor(Color.White)
  .justifyContent(FlexAlign.Center)
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
分享
微博
QQ
微信
回复
2024-12-06 17:34:33


相关问题
如何实现列表的单选效果
2916浏览 • 0回复 待解决