openharmony 鸿蒙 arkts-apis-uimaterial-sys

2026-08-25 浏览 (1)

@ohos.arkui.uiMaterial (系统材质)(系统接口)

本模块提供系统材质的接口定义。不同的系统材质对应不同的UI效果,包括背景色backgroundColor、边框颜色borderColor、边框宽度borderWidth、阴影shadow效果。

说明:

  • 本模块首批接口从API version 23开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。

  • 当前页面仅包含本模块的系统接口,公开接口参见系统材质

导入模块

import { uiMaterial } from '@kit.ArkUI';

MaterialType

系统材质类型枚举,当前页面仅包含本模块的系统接口,其他公开类型参见MaterialType

模型约束: 此接口仅可在Stage模型下使用。

系统能力: SystemCapability.ArkUI.ArkUI.Full

名称说明
NONE0无系统材质效果。对应的效果为背景色backgroundColor为透明色,边框颜色borderColor为透明色,边框宽度borderWidth为0,无阴影shadow
系统接口: 此接口为系统接口。
SEMI_TRANSPARENT1半透明系统材质效果。对应的效果为:
背景色backgroundColor:浅色模式为"#f2f1f3f5",深色模式为"#f2303131"。
边框颜色borderColor为混合10%的透明度的theme.colors.compForegroundPrimary的token值。
边框宽度borderWidth为1vp。
阴影shadow为ShadowStyle.OUTER_DEFAULT_SM。
系统接口: 此接口为系统接口。

MaterialOptions

系统材质选项。

模型约束: 此接口仅可在Stage模型下使用。

系统能力: SystemCapability.ArkUI.ArkUI.Full

系统接口: 此接口为系统接口。

名称类型只读可选说明
typeMaterialType材质类型。
默认值:MaterialType.NONE

Material

UI侧的系统材质对象。

constructor

constructor(options?: MaterialOptions)

Material的构造函数。

模型约束: 此接口仅可在Stage模型下使用。

系统能力: SystemCapability.ArkUI.ArkUI.Full

系统接口: 此接口为系统接口。

参数:

参数名类型必填说明
optionsMaterialOptions系统材质配置选项,包括材质类型。
默认值:{type:MaterialType.NONE}

示例

示例1(设置系统材质)

本示例介绍如何将半透明材质的Material对象通过systemMaterial属性设置给组件。

import { uiMaterial } from '@kit.ArkUI';

@Entry
@Component
struct SystemMaterialPage {
  build() {
    Column() {
      Stack() {
        Image($r('app.media.bg1')) // $r('app.media.bg1')需要替换为开发者所需的图像资源文件
          .width('100%')
          .height('100%')

        Column()
          .width(100)
          .height(50)
          .position({ x: 50, y: 350 })
          .systemMaterial(new uiMaterial.Material({ type: uiMaterial.MaterialType.SEMI_TRANSPARENT })) // 使用半透明的系统材质效果
      }
      .height('90%')
      .width('90%')
    }
    .height('100%')
    .width('100%')
    .alignItems(HorizontalAlign.Center)
    .justifyContent(FlexAlign.Center)
  }
}

systemMaterial

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 arkts-apis-uicontext-contextmenucontroller

openharmony 鸿蒙 errorcode-canvas

openharmony 鸿蒙 capi-oh-nativexcomponent-native-xcomponent-oh-nativexcomponent

openharmony 鸿蒙 errorcode-bindSheet

openharmony 鸿蒙 js-apis-arkui-uiExtension-sys

openharmony 鸿蒙 capi-arkui-accessibility-arkui-accessibilityeventinfo

openharmony 鸿蒙 capi-arkui-rendernodeutils

openharmony 鸿蒙 capi-native-node-h-nodeattributetype-layoutcomponent

openharmony 鸿蒙 js-apis-arkui-node

openharmony 鸿蒙 capi-native-node-h

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/bNHsdaKb