harmony 鸿蒙Security Component Universal Attributes

2023-10-30 浏览 (571)

Security Component Universal Attributes

Universal attributes of security components are basic attributes applicable to all security components.

NOTE

This component is supported since API version 10. Updates will be marked with a superscript to indicate their earliest API version.

Attributes

NameTypeMandatoryDescription
iconSizeDimensionNoIcon size of the security component.
Default value: 16vp
layoutDirectionSecurityComponentLayoutDirectionNoDirection of the icon and text on the security component.
Default value: SecurityComponentLayoutDirection.HORIZONTAL
positionPositionNoAbsolute position of the security component, that is, the offset of the component's upper left corner relative to its parent container's.
Default value:
{
x: 0,
y: 0
}
markAnchorPositionNoAnchor of the security component for moving the component with its upper left corner as the reference point. Generally, this attribute is used together with the position and offset attributes. When used alone, it produces an effect similar to that produced by offset.
Default value:
{
x: 0,
y: 0
}
offsetPositionNoRelative position of the security component, that is, the offset of the component relative to itself.
Default value:
{
x: 0,
y: 0
}
fontSizeDimensionNoFont size of the text on the security component.
Default value: 16fp
fontStyleFontStyleNoFont style of the text on the security component.
Default value: FontStyle.Normal
fontWeightnumber |FontWeight |stringNoFont weight of the text on the security component.
Default value: FontWeight.Medium
fontFamilystring |ResourceNoFont family of the text on the security component.
Default font: 'HarmonyOS Sans'
fontColorResourceColorNoFont color of the text on the security component.
Default value: '#ffffffff'
iconColorResourceColorNoColor of the icon on the security component.
Default value: '#ffffffff'
backgroundColorResourceColorNoBackground color of the security component.
Default value: #007dff
borderStyleBorderStyleNoBorder style of the security component.
By default, the border style is not set.
borderWidthDimensionNoBorder width of the security component.
By default, the border width is not set.
borderColorResourceColorNoBorder color of the security component.
By default, the border color is not set.
borderRadiusDimensionNoRadius of the rounded border corners of the security component.
paddingPadding |DimensionNoPadding of the security component.
Default value: 12 vp for the top and bottom paddings and 24 vp for the left and right paddings
textIconSpaceDimensionNoSpace between the icon and text on the security component.
Default value: 4vp

SecurityComponentLayoutDirection

NameDescription
HORIZONTALThe icon and text on security component are horizontally arranged.
VERTICALThe icon and text on security component are vertically arranged.

Example

// xxx.ets
@Entry
@Component
struct Index {
  build() {
    Row() {
      Column() {
        // Generate a save button and set its security component attributes.
        SaveButton()
          .fontSize(35)
          .fontColor(Color.White)
          .iconSize(30)
          .layoutDirection(SecurityComponentLayoutDirection.HORIZONTAL)
          .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%')
  }
}

en-us_image_0000001643038221

你可能感兴趣的鸿蒙文章

harmony 鸿蒙ArkTS-based Declarative Development Paradigm

harmony 鸿蒙@ohos.multimedia.avCastPicker (AVCastPicker)

harmony 鸿蒙Property Animation

harmony 鸿蒙Enums

harmony 鸿蒙Blank

harmony 鸿蒙Button

harmony 鸿蒙CalendarPicker

harmony 鸿蒙Checkbox

harmony 鸿蒙CheckboxGroup

harmony 鸿蒙DataPanel

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