• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Scrollable Component Common APIs
2
3The common attributes and events for scrollable components currently only support the [List](ts-container-list.md), [Grid](ts-container-grid.md), [Scroll](ts-container-scroll.md), and [WaterFlow](ts-container-waterflow.md) components.
4
5>  **NOTE**
6>
7>  The initial APIs of this module are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
8
9## Attributes
10
11### scrollBar<sup>11+</sup>
12
13scrollBar(barState: BarState): T
14
15Sets the scrollbar state.
16
17**Atomic service API**: This API can be used in atomic services since API version 11.
18
19**System capability**: SystemCapability.ArkUI.ArkUI.Full
20
21**Parameters**
22
23| Name  | Type                                     | Mandatory| Description                                  |
24| -------- | ----------------------------------------- | ---- | -------------------------------------- |
25| barState | [BarState](ts-appendix-enums.md#barstate) | Yes  | Scrollbar state.<br>Default value: **BarState.Auto** for the **List**, **Grid**, and **Scroll** components and **BarState.Off** for the **WaterFlow** component|
26
27### scrollBarColor<sup>11+</sup>
28
29scrollBarColor(color: Color | number | string): T
30
31Sets the scrollbar color.
32
33**Atomic service API**: This API can be used in atomic services since API version 11.
34
35**System capability**: SystemCapability.ArkUI.ArkUI.Full
36
37**Parameters**
38
39| Name| Type                                                        | Mandatory| Description          |
40| ------ | ------------------------------------------------------------ | ---- | -------------- |
41| color  | string \| number \| [Color](ts-appendix-enums.md#color) | Yes  | Scrollbar color.<br>Default value: **'\#182431'** (40% opacity)|
42
43### scrollBarWidth<sup>11+</sup>
44
45scrollBarWidth(value: number | string): T
46
47Sets the scrollbar width. This attribute cannot be set in percentage. After the width is set, the scrollbar is displayed with the set width in normal state and pressed state. If the set width exceeds the height of the scrollable component on the main axis, the scrollbar reverts to the default width.
48
49**Atomic service API**: This API can be used in atomic services since API version 11.
50
51**System capability**: SystemCapability.ArkUI.ArkUI.Full
52
53**Parameters**
54
55| Name| Type                      | Mandatory| Description                                     |
56| ------ | -------------------------- | ---- | ----------------------------------------- |
57| value  | string \| number | Yes  | Scrollbar width.<br>Default value: **4**<br>Unit: vp|
58
59### edgeEffect<sup>11+</sup>
60
61edgeEffect(edgeEffect: EdgeEffect, options?: EdgeEffectOptions): T
62
63Sets the effect used when the scroll boundary is reached.
64
65**Atomic service API**: This API can be used in atomic services since API version 11.
66
67**System capability**: SystemCapability.ArkUI.ArkUI.Full
68
69**Parameters**
70
71| Name               | Type                                             | Mandatory| Description                                                        |
72| --------------------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ |
73| edgeEffect            | [EdgeEffect](ts-appendix-enums.md#edgeeffect)     | Yes  | Effect used when the scroll boundary is reached. The spring and shadow effects are supported.<br>Default value: **EdgeEffect.None** for the **Grid**, **Scroll**, and **WaterFlow** components and **EdgeEffect.Spring** for the **List** component|
74| options | [EdgeEffectOptions](#edgeeffectoptions11) | No  | Whether to enable the scroll effect when the component content is smaller than the component itself. The value **{ alwaysEnabled: true }** means to enable the scroll effect, and **{ alwaysEnabled: false }** means the opposite.<br>Default value:<br>**{ alwaysEnabled: false }** for the **List**, **Grid**, and **WaterFlow** components, and **{ alwaysEnabled: true }** for the **Scroll** component|
75
76### nestedScroll<sup>11+</sup>
77
78nestedScroll(value: NestedScrollOptions): T
79
80Sets the nested scrolling options. You can set the nested scrolling mode in the forward and backward directions to implement scrolling linkage with the parent component.
81
82**Atomic service API**: This API can be used in atomic services since API version 11.
83
84**System capability**: SystemCapability.ArkUI.ArkUI.Full
85
86**Parameters**
87
88| Name| Type                                                 | Mandatory| Description          |
89| ------ | ----------------------------------------------------- | ---- | -------------- |
90| value  | [NestedScrollOptions](#nestedscrolloptions10) | Yes  | Nested scrolling options.|
91
92### enableScrollInteraction<sup>11+</sup>
93
94enableScrollInteraction(value: boolean): T
95
96Sets whether to support scroll gestures. When this attribute is set to **false**, scrolling by finger or mouse is not supported, but the scroll controller API is not affected.
97
98**Atomic service API**: This API can be used in atomic services since API version 11.
99
100**System capability**: SystemCapability.ArkUI.ArkUI.Full
101
102**Parameters**
103
104| Name| Type   | Mandatory| Description                               |
105| ------ | ------- | ---- | ----------------------------------- |
106| value  | boolean | Yes  | Whether to support scroll gestures.<br>Default value: **true**|
107
108### friction<sup>11+</sup>
109
110friction(value: number | Resource): T
111
112Sets the friction coefficient. It applies only to gestures in the scrolling area, and it affects only indirectly the scroll chaining during the inertial scrolling process. If this attribute is set to a value less than or equal to 0, the default value is used.
113
114**Atomic service API**: This API can be used in atomic services since API version 11.
115
116**System capability**: SystemCapability.ArkUI.ArkUI.Full
117
118**Parameters**
119
120| Name| Type                                                | Mandatory| Description                                                     |
121| ------ | ---------------------------------------------------- | ---- | --------------------------------------------------------- |
122| value  | number \| [Resource](ts-types.md#resource) | Yes  | Friction coefficient.<br>Default value: **0.9** for wearable devices and **0.6** for non-wearable devices<br>Since API version 11, the default value for non-wearable devices is **0.7**.<br>Since API version 12, the default value for non-wearable devices is **0.75**.|
123
124### flingSpeedLimit<sup>11+</sup>
125
126flingSpeedLimit(speedLimit: number): T
127
128Sets the maximum initial velocity at the start of the fling animation that occurs after gesture-driven scrolling ends. If this attribute is set to a value less than or equal to 0, the default value is used.
129
130**Atomic service API**: This API can be used in atomic services since API version 11.
131
132**System capability**: SystemCapability.ArkUI.ArkUI.Full
133
134**Parameters**
135
136| Name    | Type  | Mandatory| Description                           |
137| ---------- | ------ | ---- | ------------------------------- |
138| speedLimit | number | Yes  | Maximum initial velocity at the start of the fling animation.<br>Default value: **9000**<br>Unit: vp/s|
139
140### fadingEdge<sup>14+</sup>
141
142fadingEdge(enabled: Optional&lt;boolean&gt;, options?: FadingEdgeOptions): T
143
144Sets whether to enable the edge fading effect and the length of the fading edge.
145
146**Atomic service API**: This API can be used in atomic services since API version 14.
147
148**System capability**: SystemCapability.ArkUI.ArkUI.Full
149
150**Parameters**
151
152| Name | Type                                             | Mandatory| Description                                                        |
153| ------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ |
154| enabled | Optional&lt;boolean&gt;                           | Yes  | Whether to enable the edge fading effect.<br>When **fadingEdge** is set to **true**, it overrides the **.overlay()** attribute of the component.<br>With **fadingEdge** set to **true**, avoid setting background-related attributes on the component, as this may affect the display of the fading effect.<br>With **fadingEdge** set to **true**, the component is clipped to the boundary, and setting the component's **clip** attribute to **false** will not take effect.<br>Default value: **false**|
155| options | [FadingEdgeOptions](#fadingedgeoptions14) | No  | Object defining edge fading effect properties, such as the fading edge length.|
156
157### clipContent<sup>14+</sup>
158
159clipContent(clip: ContentClipMode | RectShape): T
160
161Sets the content clipping area for this scrollable component.
162
163**Atomic service API**: This API can be used in atomic services since API version 14.
164
165**System capability**: SystemCapability.ArkUI.ArkUI.Full
166
167**Parameters**
168
169| Name | Type                                             | Mandatory| Description                                                        |
170| ------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ |
171| clip | [ContentClipMode](#contentclipmode14) \| [RectShape](../js-apis-arkui-shape.md#rectshape)   | Yes  | Clipping to apply, which is effective only for the content (that is, child components) of the scrollable component, not the background. When a custom rectangular area is passed through **RectShape**, only width, height, and [offset](../js-apis-arkui-shape.md#offset) relative to the component's upper left corner are supported, and rounded corners are not supported.<br></div>Default value: The default value for **Grid** and **Scroll** is **ContentClipMode.BOUNDARY**, and the default value for **List** and **WaterFlow** is **ContentClipMode.CONTENT_ONLY**.|
172
173### backToTop<sup>15+</sup>
174
175backToTop(backToTop: boolean)
176
177Sets whether to enable the back-to-top feature for a scrollable component when the status bar is touched.
178
179If this feature is enabled, the scrollable component on the current page scrolls to the top when the user touches the status bar. This behavior does not affect scrollable components in background applications, which will not scroll to the top. This attribute is independent of the [enableScrollInteraction](#enablescrollinteraction11) setting.
180
181**Atomic service API**: This API can be used in atomic services since API version 15.
182
183**System capability**: SystemCapability.ArkUI.ArkUI.Full
184
185**Parameters**
186
187| Name| Type   | Mandatory| Description                                          |
188| ------ | ------- | ---- | ---------------------------------------------- |
189| backToTop  | boolean | Yes  | Whether to enable the back-to-top feature for a scrollable component when the status bar is touched.<br>Default value: **false**|
190
191
192
193## Events
194
195### onReachStart<sup>11+</sup>
196
197onReachStart(event: () => void): T
198
199Triggered when the scrollable component reaches the start position.
200
201This event is triggered once when the component is initialized and once when the component scrolls to the start position. If the edge effect is set to a spring effect, this event is triggered once when the swipe passes the start position, and triggered again when the swipe rebounds back to the start position.
202
203**Atomic service API**: This API can be used in atomic services since API version 11.
204
205**System capability**: SystemCapability.ArkUI.ArkUI.Full
206
207### onReachEnd<sup>11+</sup>
208
209onReachEnd(event: () => void): T
210
211Triggered when the scrollable component reaches the end position.
212
213If the edge effect is set to a spring effect, this event is triggered once when the swipe passes the end position, and triggered again when the swipe rebounds back to the end position.
214
215**Atomic service API**: This API can be used in atomic services since API version 11.
216
217**System capability**: SystemCapability.ArkUI.ArkUI.Full
218
219### onScrollStart<sup>11+</sup>
220
221onScrollStart(event: () => void): T
222
223Triggered when the scrollable component starts scrolling initiated by the user's finger dragging the component or its scrollbar. This event is also triggered when the animation contained in the scrolling triggered by [Scroller](ts-container-scroll.md#scroller) starts.
224
225**NOTE**
226
2271. This event is triggered when the scrollable component starts to scroll, and it supports various input methods that can initiate the scroll, including keyboard and mouse operations.
228
2292. This event is triggered when the controller API is called, accompanied by a transition animation.
230
231**Atomic service API**: This API can be used in atomic services since API version 11.
232
233**System capability**: SystemCapability.ArkUI.ArkUI.Full
234
235### onScrollStop<sup>11+</sup>
236
237onScrollStop(event: () => void): T
238
239Triggered when scrolling stops after the user's finger leaves the screen. This event is also triggered when the animation contained in the scrolling triggered by [Scroller](ts-container-scroll.md#scroller) stops.
240
241**NOTE**
242
2431. The event is triggered when the scrollable component stops scrolling, and it supports various input methods that can initiate the scroll, including keyboard and mouse operations.
244
2452. This event is triggered when the controller API is called, accompanied by a transition animation.
246
247**Atomic service API**: This API can be used in atomic services since API version 11.
248
249**System capability**: SystemCapability.ArkUI.ArkUI.Full
250
251### onWillScroll<sup>12+</sup>
252
253onWillScroll(handler: Optional&lt;OnWillScrollCallback&gt;): T
254
255Triggered when the scrollable component is about to scroll.
256
257The callback provides the amount of offset that is about to be scrolled in the current frame, along with the current scroll status and the source of the scrolling operation. The offset provided in the callback is the calculated intended scrolling offset, not the final actual scrolling offset. You can specify the intended scrolling offset for the scrollable component through the return value of this callback.
258
259**Atomic service API**: This API can be used in atomic services since API version 12.
260
261**System capability**: SystemCapability.ArkUI.ArkUI.Full
262
263**Parameters**
264
265| Name| Type| Mandatory| Description|
266| ------ | ------ | ------ | ------|
267| handler | Optional&lt;[OnWillScrollCallback](#onwillscrollcallback12)&gt; | Yes| Callback triggered when the scrollable component is about to scroll.|
268
269> **NOTE**
270>
271> When **ScrollEdge** and **ScrollToIndex** that does not involve animation is called, **onWillScroll** is not invoked.
272
273
274### onDidScroll<sup>12+</sup>
275
276onDidScroll(handler: OnScrollCallback): T
277
278Triggered when the scrollable component scrolls. The return value is the offset amount by which the list has scrolled and the current scroll state.
279
280**Widget capability**: This API can be used in ArkTS widgets since API version 12.
281
282**Atomic service API**: This API can be used in atomic services since API version 12.
283
284**System capability**: SystemCapability.ArkUI.ArkUI.Full
285
286**Parameters**
287
288| Name| Type| Mandatory| Description|
289| ------ | ------ | ------ | ------|
290| handler | [OnScrollCallback](#onscrollcallback12) | Yes| Callback triggered when the scrollable component scrolls.|
291
292### onScroll<sup>(deprecated)</sup>
293
294onScroll(event: (scrollOffset: number, scrollState: ScrollState) => void): T
295
296Triggered when the scrollable component scrolls.
297
298This API is supported since API version 11.
299
300This API is deprecated since API version 12. For the **Scroll** component, the **onScroll** event is triggered before layout calculations, and you are advised to use [onWillScroll](#onwillscroll12) instead. For the **List**, Grid, and **WaterFlow** components, the **onScroll** event is triggered after layout calculations, and you are advised to use [onDidScroll](#ondidscroll12) instead.
301
302**Atomic service API**: This API can be used in atomic services since API version 11.
303
304**System capability**: SystemCapability.ArkUI.ArkUI.Full
305
306**Parameters**
307
308| Name| Type| Mandatory| Description|
309| ------ | ------ | ------ | ------|
310| scrollOffset | number | Yes| Scroll offset of each frame. The offset is positive when the scrollable component is scrolled up and negative when it is scrolled down.<br>Unit: vp|
311| scrollState | [ScrollState](ts-container-list.md#scrollstate)| Yes| Current scroll state.|
312
313## ItemDragInfo
314
315**Atomic service API**: This API can be used in atomic services since API version 11.
316
317**System capability**: SystemCapability.ArkUI.ArkUI.Full
318
319| Name        | Type        |   Description        |
320| ---------- | ---------- | ---------- |
321| x | number |  X coordinate of the dragged item, in vp.   |
322| y | number |  Y coordinate of the dragged item, in vp.   |
323
324## NestedScrollOptions<sup>10+</sup>
325
326**Atomic service API**: This API can be used in atomic services since API version 11.
327
328**System capability**: SystemCapability.ArkUI.ArkUI.Full
329
330| Name  | Type | Mandatory| Description             |
331| ----- | ------ | ------ | ----------------- |
332| scrollForward | [NestedScrollMode](ts-appendix-enums.md#nestedscrollmode10) | Yes| Nested scrolling options when the scrollable component scrolls forward.|
333| scrollBackward | [NestedScrollMode](ts-appendix-enums.md#nestedscrollmode10) | Yes| Nested scrolling options when the scrollable component scrolls backward.|
334
335## EdgeEffectOptions<sup>11+</sup>
336
337**Atomic service API**: This API can be used in atomic services since API version 12.
338
339**System capability**: SystemCapability.ArkUI.ArkUI.Full
340
341| Name  | Type | Mandatory| Description             |
342| ----- | ------| ------- | ----------------- |
343| alwaysEnabled | boolean | Yes| Whether to enable the scroll effect when the component content is smaller than the component itself.|
344
345## FadingEdgeOptions<sup>14+</sup>
346
347**Atomic service API**: This API can be used in atomic services since API version 14.
348
349**System capability**: SystemCapability.ArkUI.ArkUI.Full
350
351| Name          | Type                                                        | Mandatory| Description                                                        |
352| ---------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
353| fadingEdgeLength | [LengthMetrics](../js-apis-arkui-graphics.md#lengthmetrics12) | No  | Length of the fading edge. If the value is smaller than 0, the default length, 32 vp, is used.<br>If the value exceeds half the height of the container, it is adjusted to exactly half the height of the container.|
354
355## ContentClipMode<sup>14+</sup>
356
357Enumerates the content clipping modes for the scrollable container.
358
359**Atomic service API**: This API can be used in atomic services since API version 14.
360
361**System capability**: SystemCapability.ArkUI.ArkUI.Full
362
363The figure below illustrates the clipping areas corresponding to each enumeration value after the component has been configured with margin and padding attributes.
364
365![ContentClipMode](figures/ContentClipMode.png)
366
367| Name    |  Value | Description                                      |
368| ------ | ------ | ---------------------------------------- |
369| CONTENT_ONLY   |  0  | Clip to the content area, corresponding to the green area in the figure.|
370| BOUNDARY |  1  | Clip to the component area, corresponding to the entire blue area in the figure.|
371| SAFE_AREA  |  2  | Clip to the safe area configured for the component, corresponding to the entire yellow area in the figure.|
372
373## OnWillScrollCallback<sup>12+</sup>
374
375type OnWillScrollCallback = (scrollOffset: number, scrollState: ScrollState, scrollSource: ScrollSource) => void | ScrollResult
376
377Callback triggered when the scrollable component is about to scroll.
378
379**Atomic service API**: This API can be used in atomic services since API version 12.
380
381**System capability**: SystemCapability.ArkUI.ArkUI.Full
382
383**Parameters**
384
385| Name| Type| Mandatory| Description|
386| ------ | ------ | ------ | ------|
387| scrollOffset | number | Yes| Scroll offset of each frame. The offset is positive when the scrollable component is scrolled up and negative when it is scrolled down.<br>Unit: vp|
388| scrollState | [ScrollState](ts-container-list.md#scrollstate)| Yes| Current scroll state.|
389| scrollSource | [ScrollSource](ts-appendix-enums.md#scrollsource12) | Yes| Source of the current scrolling operation.|
390
391**Return value**
392
393| Type                         | Description                                 |
394| ----------------------------- | ------------------------------------ |
395| void \| [ScrollResult](#scrollresult12) |  Returns a **ScrollResult** object if the scrollable component scrolls by the offset specified by you; returns no **ScrollResult** object if the component scrolls by the offset specified by **scrollOffset** in the callback.|
396
397## OnScrollCallback<sup>12+</sup>
398
399type OnScrollCallback = (scrollOffset: number, scrollState: ScrollState) => void
400
401Callback triggered when the scrollable component scrolls.
402
403**Widget capability**: This API can be used in ArkTS widgets since API version 12.
404
405**Atomic service API**: This API can be used in atomic services since API version 12.
406
407**System capability**: SystemCapability.ArkUI.ArkUI.Full
408
409| Name| Type| Mandatory| Description|
410| ------ | ------ | ------ | ------|
411| scrollOffset | number | Yes| Scroll offset of each frame. The offset is positive when the scrollable component is scrolled up and negative when it is scrolled down.<br>Unit: vp|
412| scrollState | [ScrollState](ts-container-list.md#scrollstate)| Yes| Current scroll state.|
413
414## ScrollResult<sup>12+</sup>
415
416**Atomic service API**: This API can be used in atomic services since API version 12.
417
418**System capability**: SystemCapability.ArkUI.ArkUI.Full
419
420| Name| Type| Mandatory| Description|
421| ------ | ------ | ------ | ------|
422| offsetRemain | number | Yes| Amount by which the component is about to be scrolled, in vp.|
423
424## ChildrenMainSize<sup>12+</sup>
425
426Provides the size information of the child components of the **List** or **ListItemGroup** component along the main axis. This object only supports one-to-one binding to the **List** or **ListItemGroup** component.
427
428**Atomic service API**: This API can be used in atomic services since API version 12.
429
430### constructor<sup>12+</sup>
431
432constructor(childDefaultSize: number): void
433
434A constructor used to create a **ChildrenMainSize** object.
435
436**Atomic service API**: This API can be used in atomic services since API version 12.
437
438**System capability**: SystemCapability.ArkUI.ArkUI.Full
439
440**Parameters**
441
442| Name  | Type                           | Mandatory  | Description                  |
443| ---- | ----------------------------- | ---- | -------------------- |
444| childDefaultSize | number | Yes   | Default size of the child component along the main axis.<br>Unit: vp<br>**NOTE**<br>The value must be a finite non-negative number; otherwise, an exception will be thrown.|
445
446
447### childDefaultSize<sup>12+</sup>
448
449set childDefaultSize(value: number): void
450
451Sets the default size of the child component along the main axis.
452
453**Atomic service API**: This API can be used in atomic services since API version 12.
454
455**System capability**: SystemCapability.ArkUI.ArkUI.Full
456
457**Parameters**
458
459| Name  | Type                           | Mandatory  | Description                  |
460| ---- | ----------------------------- | ---- | -------------------- |
461| value | number | Yes   | Default size of the child component along the main axis.<br>Unit: vp<br>**NOTE**<br>The value must be a finite non-negative number; otherwise, an exception will be thrown.|
462
463**Error codes**
464
465For details about the error codes, see [Universal Error Codes](../../errorcode-universal.md).
466
467| ID| Error Message|
468| ------- | -------- |
469| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3. Parameter verification failed.   |
470
471get childDefaultSize(): number
472
473Obtains the default size of the child component along the main axis.
474
475**Atomic service API**: This API can be used in atomic services since API version 12.
476
477**System capability**: SystemCapability.ArkUI.ArkUI.Full
478
479**Return value**
480
481| Type                                                        | Description                                                        |
482| ------------------------------------------------------------ | ------------------------------------------------------------ |
483| number | Default size of the child component along the main axis.<br>Unit: vp|
484
485### splice<sup>12+</sup>
486
487splice(start: number, deleteCount?: number, childrenSize?: Array\<number>): void
488
489Performs batch operations to add, delete, or modify the size information of child components along the main axis.
490
491**Atomic service API**: This API can be used in atomic services since API version 12.
492
493**System capability**: SystemCapability.ArkUI.ArkUI.Full
494
495**Parameters**
496
497| Name  | Type                           | Mandatory  | Description                  |
498| ---- | ----------------------------- | ---- | -------------------- |
499| start | number | Yes   | Index starting from 0, which indicates the position at which to begin modifying the size information of child components along the main axis.<br>**NOTE**<br>1. The value must be a finite non-negative number; otherwise, an exception will be thrown.<br>2. Non-integer values are truncated to the nearest integer.<br>3. Values exceeding the maximum index do not take effect.|
500| deleteCount | number | No   | Number of size information entries to be deleted starting from the **start** position.<br>**NOTE**<br>1.  The value must be a finite non-negative number; otherwise, it will be treated as **0**.<br>2. Non-integer values are truncated to the nearest integer.<br>3. The result of (start + deleteCount - 1) can exceed the maximum index, which will delete all size information of child components starting from the **start** position.|
501| childrenSize | Array\<number > | No   | Size information of all child components to be inserted, starting from the **start** position.<br>Unit for each value in the array: vp<br>**NOTE**<br>1. If the values in the array are finite non-negative number, they are considered specified sizes and will not change with the default size.<br>2. 2. If the values in the array are not finite non-negative number, they will be treated as the default size and will change with the default size. |
502
503
504**Error codes**
505
506For details about the error codes, see [Universal Error Codes](../../errorcode-universal.md).
507
508| ID| Error Message|
509| ------- | -------- |
510| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3. Parameter verification failed.   |
511
512
513> **NOTE**
514>
515> - If only the **start** parameter is used, it means to delete the size information of the child components starting from the **start** position and beyond.
516> - If only the **start** and **deleteCount** parameters are used, it means to delete the **deleteCount**-specified number of size information entries starting from the **start** position. This is generally used when you remove child components.
517> - If all three parameters are used, it means to delete the **deleteCount**-specified number of size information entries starting from the **start** position, and then insert all the size information from **childrenSize** at the **start** position. This is generally used when you add child components or batch update the main axis size of child components. If it's only about adding child components, **deleteCount** should be **0**, and the number of elements in **childrenSize** should be equal to the number of child components being added. If it's only about batch updating the main axis size of child components, the number of elements in **childrenSize** should be equal to **deleteCount**, which is the number of updates being made.
518> - If you want to notify that the size of a child component should be the default size, the corresponding value in **childrenSize** should not be given as a finite non-negative value, but rather as **NaN**, any negative value, or any other value that can be processed as the default size.
519
520### update<sup>12+</sup>
521
522update(index: number, childSize: number): void
523
524Updates the main axis size information of the child component corresponding to the specified index.
525
526**Atomic service API**: This API can be used in atomic services since API version 12.
527
528**System capability**: SystemCapability.ArkUI.ArkUI.Full
529
530**Parameters**
531
532| Name  | Type                           | Mandatory  | Description                  |
533| ---- | ----------------------------- | ---- | -------------------- |
534| index | number | Yes   | Index starting from 0, which indicates the position at which to begin modifying the size information of child components along the main axis.<br>**NOTE**<br>1. The value must be a finite non-negative number; otherwise, an exception will be thrown.<br>2. Non-integer values are truncated to the nearest integer.<br>3. Values exceeding the maximum index do not take effect.|
535| childSize | number | Yes   | Size to be updated to.<br>Unit: vp<br>**NOTE**<br>1. If the value is a finite non-negative number, it is considered a specified size and will not change with the default size.<br>2. 2. If the value is not a finite non-negative number, it will be processed as the default size and will change with the default size. |
536
537**Error codes**
538
539For details about the error codes, see [Universal Error Codes](../../errorcode-universal.md).
540
541| ID| Error Message|
542| ------- | -------- |
543| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3. Parameter verification failed.   |
544