harmony 鸿蒙SecurityComponent

2023-06-24 浏览 (934)

SecurityComponent

安全控件的基础属性,用于设置安全控件通用的属性。

说明:

该组件从API Version 10开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。

属性

名称参数类型必填描述
iconSizeLength设置安全控件上图标的尺寸。
默认值:16vp
layoutDirectionSecurityComponentLayoutDirection设置安全控件上图标和文字分布的方向。
默认值:SecurityComponentLayoutDirection.HORIZONTAL
layoutOrderSecurityComponentLayoutOrder设置安全控件上图标和文字分布的顺序。
默认值:SecurityComponentLayoutOrder.ICON_FIRST
positionPosition设置绝对定位,设置安全控件的左上角相对于父容器左上角的偏移位置。
默认值:
{
x: 0,
y: 0
}
markAnchorPosition设置绝对定位的锚点,以安全控件的左上角作为基准点进行偏移。
默认值:
{
x: 0,
y: 0
}
offsetPosition设置相对定位,安全控件相对于自身的偏移量。
默认值:
{
x: 0,
y: 0
}
fontSizeLength设置安全控件上文字的尺寸。
默认值:16fp
fontStyleFontStyle设置安全控件上文字的样式。
默认值:FontStyle.Normal
fontWeightnumber |FontWeight |string设置安全控件上文字粗细。
默认值:FontWeight.Medium
fontFamilystring |Resource设置安全控件上文字的字体。
默认字体:'HarmonyOS Sans'
fontColorResourceColor设置安全控件上文字的颜色。
默认值:#ffffffff
iconColorResourceColor设置安全控件上图标的颜色。
默认值:#ffffffff
backgroundColorResourceColor设置安全控件的背景颜色。
默认值:#007dff
borderStyleBorderStyle设置安全控件的边框的样式。
默认不设置边框样式
borderWidthLength设置安全控件的边框的宽度。
默认不设置边框宽度
borderColorResourceColor设置安全控件的边框的颜色。
默认不设置边框颜色
borderRadiusLength设置安全控件的边框圆角半径。
默认值:1/2 按钮整高
paddingPadding |Length设置安全控件的内边距。
默认值:上下8vp, 左右24vp
textIconSpaceLength设置安全控件中图标和文字的间距。
默认值:4vp

SecurityComponentLayoutDirection枚举说明

名称描述
HORIZONTAL安全控件上图标和文字分布的方向为水平排列。
VERTICAL安全控件上图标和文字分布的方向为垂直排列。

SecurityComponentLayoutOrder枚举说明

名称描述
ICON_FIRST图标的排列顺序先于文字。
TEXT_FIRST文字的排列顺序先于图标。

示例

// xxx.ets
@Entry
@Component
struct Index {
  build() {
    Row() {
      Column() {
        // 生成一个保存按钮,并设置它的SecurityComponent属性
        SecSaveButton()
          .fontSize(35)
          .fontColor(Color.White)
          .iconSize(30)
          .layoutDirection(SecurityComponentLayoutDirection.HORIZONTAL)
          .layoutOrder(SecurityComponentLayoutOrder.TEXT_FIRST)
          .borderWidth(1)
          .borderStyle(BorderStyle.Dashed)
          .borderColor(Color.Blue)
          .borderRadius(20)
          .fontWeight(100)
          .iconColor(Color.White)
          .padding({left:50, top:50, bottom:50, right:50})
          .textIconSpace(20)
          .backgroundColor(0x3282f6)
      }.width('100%')
    }.height('100%')
  }
}

securitycomponent1

你可能感兴趣的鸿蒙文章

harmony 鸿蒙基于ArkTS的声明式开发范式

harmony 鸿蒙属性动画

harmony 鸿蒙枚举说明

harmony 鸿蒙Blank

harmony 鸿蒙Button

harmony 鸿蒙Checkbox

harmony 鸿蒙CheckboxGroup

harmony 鸿蒙DataPanel

harmony 鸿蒙DatePicker

harmony 鸿蒙Divider

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