1e41f4b71Sopenharmony_ci# Render Fit 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciThe **renderFit** attribute sets how the final state of a component's content is rendered during its width and height animation process. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **NOTE** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> The APIs of this module are supported since API version 10. Updates will be marked with a superscript to indicate their earliest API version. 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci## renderFit 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_cirenderFit(fitMode: RenderFit) 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ciSets how the final state of the component's content is rendered during its width and height animation process. 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci**Parameters** 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 22e41f4b71Sopenharmony_ci| ------- | ------------------------------- | ---- | ------------------------------------------------------------ | 23e41f4b71Sopenharmony_ci| fitMode | [RenderFit](#renderfit) | Yes | How the final state of the component's content is rendered during its width and height animation process.<br>If **renderFit** is not set, the default value **RenderFit.TOP_LEFT** is used.| 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci## RenderFit 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci| Name | Description | Diagram | 30e41f4b71Sopenharmony_ci| --------------------------- | ---------------------------------------- | ---------------------------------------- | 31e41f4b71Sopenharmony_ci| CENTER | The component's content stays at the final size and always aligned with the center of the component. |  | 32e41f4b71Sopenharmony_ci| TOP | The component's content stays at the final size and always aligned with the top center of the component. |  | 33e41f4b71Sopenharmony_ci| BOTTOM | The component's content stays at the final size and always aligned with the bottom center of the component. |  | 34e41f4b71Sopenharmony_ci| LEFT | The component's content stays at the final size and always aligned with the left of the component. |  | 35e41f4b71Sopenharmony_ci| RIGHT | The component's content stays at the final size and always aligned with the right of the component. |  | 36e41f4b71Sopenharmony_ci| TOP_LEFT | The component's content stays at the final size and always aligned with the upper left corner of the component. |  | 37e41f4b71Sopenharmony_ci| TOP_RIGHT | The component's content stays at the final size and always aligned with the upper right corner of the component. |  | 38e41f4b71Sopenharmony_ci| BOTTOM_LEFT | The component's content stays at the final size and always aligned with the lower left corner of the component. |  | 39e41f4b71Sopenharmony_ci| BOTTOM_RIGHT | The component's content stays at the final size and always aligned with the lower right corner of the component. |  | 40e41f4b71Sopenharmony_ci| RESIZE_FILL | The component's content is always resized to fill the component's content box, without considering its aspect ratio in the final state. |  | 41e41f4b71Sopenharmony_ci| RESIZE_CONTAIN | While maintaining its aspect ratio in the final state, the component's content is scaled to fit within the component's content box. It is always aligned with the center of the component.|  | 42e41f4b71Sopenharmony_ci| RESIZE_CONTAIN_TOP_LEFT | While maintaining its aspect ratio in the final state, the component's content is scaled to fit within the component's content box. When there is remaining space in the width direction of the component, the content is left-aligned with the component. When there is remaining space in the height direction of the component, the content is top-aligned with the component.|  | 43e41f4b71Sopenharmony_ci| RESIZE_CONTAIN_BOTTOM_RIGHT | While maintaining its aspect ratio in the final state, the component's content is scaled to fit within the component's content box. When there is remaining space in the width direction of the component, the content is right-aligned with the component. When there is remaining space in the height direction of the component, the content is bottom-aligned with the component.|  | 44e41f4b71Sopenharmony_ci| RESIZE_COVER | While maintaining its aspect ratio in the final state, the component's content is scaled to cover the component's entire content box. It is always aligned with the center of the component, so that its middle part is displayed.|  | 45e41f4b71Sopenharmony_ci| RESIZE_COVER_TOP_LEFT | While maintaining its aspect ratio in the final state, the component's content is scaled to cover the component's entire content box. When there is remaining space in the width direction, the content is left-aligned with the component, so that its left part is displayed. When there is remaining space in the height direction, the content is top-aligned with the component, so that its top part is displayed.|  | 46e41f4b71Sopenharmony_ci| RESIZE_COVER_BOTTOM_RIGHT | While maintaining its aspect ratio in the final state, the component's content is scaled to cover the component's entire content box. When there is remaining space in the width direction, the content is right-aligned with the component, so that its right part is displayed. When there is remaining space in the height direction, the content is bottom-aligned with the component, so that its bottom part is displayed.|  | 47e41f4b71Sopenharmony_ci 48e41f4b71Sopenharmony_ci> **NOTE** 49e41f4b71Sopenharmony_ci> 50e41f4b71Sopenharmony_ci> - In the illustrative diagrams, the blue area indicates the content, and the orange area indicates the component content box. 51e41f4b71Sopenharmony_ci> - Different render fit modes create different effects during the width and height animation process. Choose the one that best fits your need. 52e41f4b71Sopenharmony_ci 53e41f4b71Sopenharmony_ci## Example 54e41f4b71Sopenharmony_ci 55e41f4b71Sopenharmony_ci```ts 56e41f4b71Sopenharmony_ci// xxx.ets 57e41f4b71Sopenharmony_ci@Entry 58e41f4b71Sopenharmony_ci@Component 59e41f4b71Sopenharmony_cistruct RenderFitExample { 60e41f4b71Sopenharmony_ci @State width1: number = 100; 61e41f4b71Sopenharmony_ci @State height1: number = 30; 62e41f4b71Sopenharmony_ci flag: boolean = true; 63e41f4b71Sopenharmony_ci build() { 64e41f4b71Sopenharmony_ci Column() { 65e41f4b71Sopenharmony_ci Text("Hello") 66e41f4b71Sopenharmony_ci .width(this.width1) 67e41f4b71Sopenharmony_ci .height(this.height1) 68e41f4b71Sopenharmony_ci .borderWidth(1) 69e41f4b71Sopenharmony_ci .textAlign(TextAlign.Start) 70e41f4b71Sopenharmony_ci .renderFit(RenderFit.LEFT) // The component's content stays at the final size and always aligned with the left of the component. 71e41f4b71Sopenharmony_ci .margin(20) 72e41f4b71Sopenharmony_ci 73e41f4b71Sopenharmony_ci Text("Hello") 74e41f4b71Sopenharmony_ci .width(this.width1) 75e41f4b71Sopenharmony_ci .height(this.height1) 76e41f4b71Sopenharmony_ci .textAlign(TextAlign.Center) 77e41f4b71Sopenharmony_ci .borderWidth(1) 78e41f4b71Sopenharmony_ci .renderFit(RenderFit.CENTER) // The component's content stays at the final size and always aligned with the center of the component. 79e41f4b71Sopenharmony_ci .margin(20) 80e41f4b71Sopenharmony_ci 81e41f4b71Sopenharmony_ci Button("animate") 82e41f4b71Sopenharmony_ci .onClick(() => { 83e41f4b71Sopenharmony_ci animateTo({ curve: Curve.Ease }, () => { 84e41f4b71Sopenharmony_ci if (this.flag) { 85e41f4b71Sopenharmony_ci this.width1 = 150; 86e41f4b71Sopenharmony_ci this.height1 = 50; 87e41f4b71Sopenharmony_ci } else { 88e41f4b71Sopenharmony_ci this.width1 = 100; 89e41f4b71Sopenharmony_ci this.height1 = 30; 90e41f4b71Sopenharmony_ci } 91e41f4b71Sopenharmony_ci this.flag = !this.flag; 92e41f4b71Sopenharmony_ci }) 93e41f4b71Sopenharmony_ci }) 94e41f4b71Sopenharmony_ci }.width("100%").height("100%").alignItems(HorizontalAlign.Center) 95e41f4b71Sopenharmony_ci } 96e41f4b71Sopenharmony_ci} 97e41f4b71Sopenharmony_ci``` 98e41f4b71Sopenharmony_ci 99e41f4b71Sopenharmony_ci 100