openharmony 鸿蒙 ohos-arkui-advanced-ArcSlider

2025-06-12 浏览 (1)

ArcSlider

The ArcSlider component is designed for circular screens to quickly adjust settings, such as the volume and brightness.

NOTE

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

Modules to Import

import {
  ArcSlider,
  ArcSliderPosition,
  ArcSliderOptions,
  ArcSliderValueOptions,
  ArcSliderLayoutOptions,
  ArcSliderStyleOptions,
  ArcSliderValueOptionsConstructorOptions,
  ArcSliderLayoutOptionsConstructorOptions,
  ArcSliderStyleOptionsConstructorOptions,
  ArcSliderOptionsConstructorOptions
} from '@kit.ArkUI'

Child Components

Not supported

Attributes

The universal attributes are not supported.

Events

The universal events are not supported.

ArcSlider

ArcSlider({ options: ArcSliderOptions })

Creates an ArcSlider instance. The input parameter is the configuration for the arc slider.

Decorator: @Component

Atomic service API: This API can be used in atomic services since API version 18.

System capability: SystemCapability.ArkUI.ArkUI.Circle

Parameters

NameTypeMandatoryDescription
optionsArcSliderOptionsYesParameters of the arc slider.
Default value: default values of all properties of ArcSliderOptions

ArcSliderOptions

Defines the properties of the arc slider.

Decorator type: @ObservedV2

Atomic service API: This API can be used in atomic services since API version 18.

System capability: SystemCapability.ArkUI.ArkUI.Circle

NameTypeMandatoryDecoratorDescription
valueOptionsArcSliderValueOptionsNo@TraceValue of the arc slider.
Default value: default values of all properties of ArcSliderValueOptions
layoutOptionsArcSliderLayoutOptionsNo@TraceLayout of the arc slider.
Default value: default values of all properties of ArcSliderLayoutOptions
styleOptionsArcSliderStyleOptionsNo@TraceStyle of the arc slider.
Default value: default values of all properties of ArcSliderStyleOptions
digitalCrownSensitivityCrownSensitivityNo@TraceSensitivity to the digital crown rotation.
Default value: CrownSensitivity.MEDIUM
onTouchArcSliderTouchHandlerNo@TraceCallback invoked to notify the application when the arc slider is touched.
If no value is provided, no callback is performed.
onChangeArcSliderChangeHandlerNo@TraceCallback invoked to notify the application when the progress value of the arc slider changes.
If no value is provided, no callback is performed.
onEnlargeArcSliderEnlargeHandlerNo@TraceCallback invoked to notify the application when the arc slider is zoomed in or out.
If no value is provided, no callback is performed.

constructor

constructor(options?: ArcSliderOptionsConstructorOptions)

A constructor used to create an ArcSliderOptions instance.

Atomic service API: This API can be used in atomic services since API version 18.

System capability: SystemCapability.ArkUI.ArkUI.Circle

Parameters

NameTypeMandatoryDescription
optionsArcSliderOptionsConstructorOptionsNoConstruction information for ArcSliderOptions.

ArcSliderValueOptions

Defines the value of the arc slider.

Decorator type: @ObservedV2

Atomic service API: This API can be used in atomic services since API version 18.

System capability: SystemCapability.ArkUI.ArkUI.Circle

NameTypeMandatoryDecoratorDescription
progressnumberNo@TraceCurrent progress.
Default value: same as the value of min
minnumberNo@TraceMinimum value.
Default value: 0
maxnumberNo@TraceMaximum value.
Default value: 100
NOTE
If the value of min is greater than or equal to that of max, min is set to 0 and max 100.
If the value is not within the [min, max] range, the value of min or max is used, whichever is closer.

constructor

constructor(options?: ArcSliderValueOptionsConstructorOptions)

A constructor used to create an ArcSliderValueOptions instance.

Atomic service API: This API can be used in atomic services since API version 18.

System capability: SystemCapability.ArkUI.ArkUI.Circle

Parameters

NameTypeMandatoryDescription
optionsArcSliderValueOptionsConstructorOptionsNoConstruction information for ArcSliderValueOptions.

ArcSliderLayoutOptions

Defines the layout of the arc slider.

Decorator type: @ObservedV2

Atomic service API: This API can be used in atomic services since API version 18.

System capability: SystemCapability.ArkUI.ArkUI.Circle

NameTypeMandatoryDecoratorDescription
reversebooleanNo@TraceWhether the value range of the arc slider is reversed.
Default value: true (swipe from bottom to top)
positionArcSliderPositionNo@TracePosition of the arc slider on the screen.
Default value: ArcSliderPosition.RIGHT

constructor

constructor(options?: ArcSliderLayoutOptionsConstructorOptions)

A constructor used to create an ArcSliderLayoutOptions instance.

Atomic service API: This API can be used in atomic services since API version 18.

System capability: SystemCapability.ArkUI.ArkUI.Circle

Parameters

NameTypeMandatoryDescription
optionsArcSliderLayoutOptionsConstructorOptionsNoConstruction information for ArcSliderLayoutOptions.

ArcSliderStyleOptions

Defines the style of the arc slider.

Decorator type: @ObservedV2

Atomic service API: This API can be used in atomic services since API version 18.

System capability: SystemCapability.ArkUI.ArkUI.Circle

NameTypeMandatoryDecoratorDescription
trackThicknessnumberNo@TraceStroke width of the arc slider in the normal state, in vp.
Default value: 5
The value ranges from 5 to 16. If an invalid value is set, the default value is used.
activeTrackThicknessnumberNo@TraceStroke width of the arc slider when it is zoomed in, in vp.
Default value: 24
The value ranges from 24 to 36. If an invalid value is set, the default value is used.
trackColorstringNo@TraceBackground color of the stroke.
Default value: #33FFFFFF
selectedColorstringNo@TraceHighlight color of the stroke.
Default value: #FF5EA1FF
trackBlurnumberNo@TraceBlur effect applied to the stroke background, in vp.
Default value: 20
If a value less than 0 is set, the default value is used.

constructor

constructor(options?: ArcSliderStyleOptionsConstructorOptions)

A constructor used to create an ArcSliderStyleOptions instance.

Atomic service API: This API can be used in atomic services since API version 18.

System capability: SystemCapability.ArkUI.ArkUI.Circle

Parameters

NameTypeMandatoryDescription
optionsArcSliderStyleOptionsConstructorOptionsNoConstruction information for ArcSliderStyleOptions.

ArcSliderPosition

Defines the position of the arc slider on the screen.

Atomic service API: This API can be used in atomic services since API version 18.

System capability: SystemCapability.ArkUI.ArkUI.Circle

NameValueDescription
LEFT0The arc slider is displayed on the left.
RIGHT1The arc slider is displayed on the right.

ArcSliderTouchHandler

type ArcSliderTouchHandler = (event: TouchEvent) => void

Defines the callback invoked to notify the application when the arc slider is touched.

Atomic service API: This API can be used in atomic services since API version 18.

System capability: SystemCapability.ArkUI.ArkUI.Circle

Parameters

NameTypeMandatoryDescription
eventTouchEventYesTouchEvent object.

ArcSliderChangeHandler

type ArcSliderChangeHandler = (progress: number) => void

Defines the callback invoked to notify the application when the progress value of the arc slider changes.

Atomic service API: This API can be used in atomic services since API version 18.

System capability: SystemCapability.ArkUI.ArkUI.Circle

Parameters

NameTypeMandatoryDescription
progressnumberYesCurrent progress of the slider.

ArcSliderEnlargeHandler

type ArcSliderEnlargeHandler = (isEnlarged: boolean) => void

Defines the callback invoked to notify the application when the arc slider is zoomed in or out.

Atomic service API: This API can be used in atomic services since API version 18.

System capability: SystemCapability.ArkUI.ArkUI.Circle

Parameters

NameTypeMandatoryDescription
isEnlargedbooleanYesWhether the arc slider is zoomed in.
false: The arc slider is zoomed out.
true: The arc slider is zoomed in.

ArcSliderOptionsConstructorOptions

Defines the construction information for ArcSliderOptions.

Atomic service API: This API can be used in atomic services since API version 18.

System capability: SystemCapability.ArkUI.ArkUI.Circle

NameTypeMandatoryDescription
valueOptionsArcSliderValueOptionsNoValue of the arc slider.
Default value: default values of all properties of ArcSliderValueOptions
layoutOptionsArcSliderLayoutOptionsNoLayout of the arc slider.
Default value: default values of all properties of ArcSliderLayoutOptions
styleOptionsArcSliderStyleOptionsNoStyle of the arc slider.
Default value: default values of all properties of ArcSliderStyleOptions
digitalCrownSensitivityCrownSensitivityNoSensitivity to the digital crown rotation.
Default value: CrownSensitivity.MEDIUM
onTouchArcSliderTouchHandlerNoCallback invoked to notify the application when the arc slider is touched.
If no value is provided, no callback is performed.
onChangeArcSliderChangeHandlerNoCallback invoked to notify the application when the progress value of the arc slider changes.
If no value is provided, no callback is performed.
onEnlargeArcSliderEnlargeHandlerNoCallback invoked to notify the application when the arc slider is zoomed in or out.
If no value is provided, no callback is performed.

ArcSliderValueOptionsConstructorOptions

Defines the construction information for ArcSliderValueOptions.

Atomic service API: This API can be used in atomic services since API version 18.

System capability: SystemCapability.ArkUI.ArkUI.Circle

NameTypeMandatoryDescription
progressnumberNoCurrent progress.
Default value: same as the value of min
minnumberNoMinimum value.
Default value: 0
maxnumberNoMaximum value.
Default value: 100
NOTE
If the value of min is greater than or equal to that of max, min is set to 0 and max 100.
If the value is not within the [min, max] range, the value of min or max is used, whichever is closer.

ArcSliderLayoutOptionsConstructorOptions

Defines the construction information for ArcSliderStyleOptions.

Atomic service API: This API can be used in atomic services since API version 18.

System capability: SystemCapability.ArkUI.ArkUI.Circle

NameTypeMandatoryDescription
reversebooleanNoWhether the value range of the arc slider is reversed.
Default value: true (swipe from bottom to top)
positionArcSliderPositionNoPosition of the arc slider on the screen.
Default value: ArcSliderPosition.RIGHT

ArcSliderStyleOptionsConstructorOptions

Defines the construction information for ArcSliderStyleOptions.

Atomic service API: This API can be used in atomic services since API version 18.

System capability: SystemCapability.ArkUI.ArkUI.Circle

NameTypeMandatoryDescription
trackThicknessnumberNoStroke width of the arc slider in the normal state, in vp.
Default value: 5
The value ranges from 5 to 16. If an invalid value is set, the default value is used.
activeTrackThicknessnumberNoStroke width of the arc slider when it is zoomed in, in vp.
Default value: 24
The value ranges from 24 to 36. If an invalid value is set, the default value is used.
trackColorstringNoBackground color of the stroke.
Default value: #33FFFFFF
selectedColorstringNoHighlight color of the stroke.
Default value: #FF5EA1FF
trackBlurnumberNoBlur effect applied to the stroke background, in vp.
Default value: 20
If a value less than 0 is set, the default value is used.

Example

// xxx.ets
import {
  ArcSlider,
  ArcSliderPosition,
  ArcSliderOptions,
  ArcSliderValueOptions,
  ArcSliderLayoutOptions,
  ArcSliderStyleOptions,
  ArcSliderValueOptionsConstructorOptions,
  ArcSliderLayoutOptionsConstructorOptions,
  ArcSliderStyleOptionsConstructorOptions,
  ArcSliderOptionsConstructorOptions
} from '@kit.ArkUI'

@Entry
@ComponentV2
struct ArcSliderExample {
  valueOptionsConstructorOptions: ArcSliderValueOptionsConstructorOptions = {
    progress: 60,
    min: 10,
    max: 110
  }

  layoutOptionsConstructorOptions: ArcSliderLayoutOptionsConstructorOptions = {
    reverse: true,
    position: ArcSliderPosition.RIGHT
  }
  styleOptionsConstructorOptions: ArcSliderStyleOptionsConstructorOptions = {
    trackThickness: 8,
    activeTrackThickness: 30,
    trackColor: '#ffd5d5d5',
    selectedColor: '#ff2787d9',
    trackBlur: 20
  }
  valueOptions: ArcSliderValueOptions = new ArcSliderValueOptions(this.valueOptionsConstructorOptions)
  layoutOptions: ArcSliderLayoutOptions = new ArcSliderLayoutOptions(this.layoutOptionsConstructorOptions)
  styleOptions: ArcSliderStyleOptions = new ArcSliderStyleOptions(this.styleOptionsConstructorOptions)
  arcSliderOptionsConstructorOptions: ArcSliderOptionsConstructorOptions = {
    valueOptions: this.valueOptions,
    layoutOptions: this.layoutOptions,
    styleOptions: this.styleOptions,
    digitalCrownSensitivity:CrownSensitivity.LOW,
    onTouch: (event: TouchEvent) => {
    },
    onChange: (progress: number) => {
    },
    onEnlarge: (isEnlarged: boolean) => {
    }
  }
  arcSliderOptions: ArcSliderOptions = new ArcSliderOptions(this.arcSliderOptionsConstructorOptions)

  build() {
    Column() {
      ArcSlider({ options: this.arcSliderOptions })}
      .width('100%')
  }
}

arcslider

你可能感兴趣的鸿蒙文章

harmony 鸿蒙ArcButton

harmony 鸿蒙Chip

harmony 鸿蒙ChipGroup

harmony 鸿蒙ComposeListItem

harmony 鸿蒙ComposeTitleBar

harmony 鸿蒙advanced.Counter

harmony 鸿蒙Dialog Box (Dialog)

harmony 鸿蒙DialogV2

harmony 鸿蒙DownloadFileButton

harmony 鸿蒙EditableTitleBar

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