HarmonyOS 阴影设置问题?

HarmonyOS能否设置单边阴影,就是只有下侧有阴影,其他侧没有的那种。

阅读 605
1 个回答

顶部边框阴影设置暂只支持容器组件的shadow属性,可以通过设置最外层组件的底部margin及背景色,如果想要阴影效果,可以考虑使用foregroundBlurStyle实现组件内容模糊,参考链接如下:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-universal-attributes-foreground-blur-style-V5\#foregroundblurstyle

参考示例如下:

Row() {
  // 上下左右的内边距分别为0 0 5 0
  Row() {
    Row().size({ width: '100%', height: '100%' }).backgroundColor(Color.Yellow)
  }
  .width(100)
  .height(80)
  .margin( { top: 0, left: 0, bottom: 5, right: 0 })
  .backgroundColor(Color.White)
}.backgroundColor(Color.Blue)
.foregroundBlurStyle(BlurStyle.Thin, { colorMode: ThemeColorMode.LIGHT, adaptiveColor: AdaptiveColor.DEFAULT, scale: 0.1})
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进