未验证 提交 c6a727bd 编写于 作者: O openharmony_ci 提交者: Gitee

!10729 翻译完成 9929/9822/10205/10334

Merge pull request !10729 from ester.zhou/TR-9929
...@@ -2,17 +2,15 @@ ...@@ -2,17 +2,15 @@
The **\<RichText>** component parses and displays HTML text. The **\<RichText>** component parses and displays HTML text.
> **NOTE** > **NOTE**
> >
> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. > This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
## Required Permissions
None
## Child Components ## Child Components
None Not supported
## APIs ## APIs
...@@ -20,9 +18,9 @@ RichText(content:string) ...@@ -20,9 +18,9 @@ RichText(content:string)
**Parameters** **Parameters**
| Name| Type| Mandatory| Default Value| Description| | Name| Type| Mandatory | Description|
| -------- | -------- | -------- | -------- | -------- | | ------- | -------- | ------------- | -------- |
| content | string | Yes| - | String in HTML format.| | content | string | Yes | String in HTML format.|
## Events ## Events
...@@ -49,34 +47,38 @@ RichText(content:string) ...@@ -49,34 +47,38 @@ RichText(content:string)
| \<script>\</script> | Used to embed or reference a client-side script, such as JavaScript.| \<script>document.write("Hello World!")\</script> | | \<script>\</script> | Used to embed or reference a client-side script, such as JavaScript.| \<script>document.write("Hello World!")\</script> |
## Example ## Example
You can preview how this component looks on a real device. The preview is not yet available in the DevEco Studio Previewer. You can preview how this component looks on a real device. The preview is not yet available in the DevEco Studio Previewer.
```ts ```ts
// xxx.ets // xxx.ets
@Entry @Entry
@Component @Component
struct RichTextExample { struct RichTextExample {
@State data: string = "<h1 style='text-align: center;'>h1 heading</h1>" + @State data: string = '<h1 style="text-align: center;">h1 heading</h1>' +
"<h1 style='text-align: center;'><i>h1 italic</i></h1>" + '<h1 style="text-align: center;"><i>h1 italic</i></h1>' +
"<h1 style='text-align: center;'><u>h1 underlined</u></h1>" + '<h1 style="text-align: center;"><u>h1 underlined</u></h1>' +
"<h2 style='text-align: center;'>h2 heading</h2>" + '<h2 style="text-align: center;">h2 heading</h2>' +
"<h3 style='text-align: center;'>h3 heading</h3>" + '<h3 style="text-align: center;">h3 heading</h3>' +
"<p style='text-align: center;'>Regular paragraph</p><hr/>" + '<p style="text-align: center;">Regular paragraph</p><hr/>' +
"<div style='width: 500px;height: 500px;border: 1px solid;margin: 0auto;'>" + '<div style="width: 500px;height: 500px;border: 1px solid;margin: 0auto;">' +
"<p style='font-size: 35px;text-align: center;font-weight: bold; color: rgb(24,78,228)'>Font size: 35px; line height: 45px</p>" + '<p style="font-size: 35px;text-align: center;font-weight: bold; color: rgb(24,78,228)">Font size: 35px; line height: 45px</p>' +
"<p style='background-color: #e5e5e5;line-height: 45px;font-size: 35px;text-indent: 2em;'>" + '<p style="background-color: #e5e5e5;line-height: 45px;font-size: 35px;text-indent: 2em;">' +
"<p>This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph.</p>" '<p>This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph.</p>';
build() { build() {
Flex({direction: FlexDirection.Column,alignItems: ItemAlign.Center, Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center,
justifyContent: FlexAlign.Center }){ justifyContent: FlexAlign.Center }) {
RichText(this.data) RichText(this.data)
.onStart(()=>{ .onStart(() => {
console.info("RichText onStart") console.info('RichText onStart');
}) })
.onComplete(()=>{ .onComplete(() => {
console.info("RichText onComplete") console.info('RichText onComplete');
}) })
} }
} }
} }
``` ```
![richText](figures/richText.png)
...@@ -16,7 +16,7 @@ SwipeGesture(value?: { fingers?: number; direction?: SwipeDirection; speed?: num ...@@ -16,7 +16,7 @@ SwipeGesture(value?: { fingers?: number; direction?: SwipeDirection; speed?: num
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| fingers | number | No| Minimum number of fingers to trigger a swipe gesture. The value ranges from 1 to 10.<br>Default value: **1**| | fingers | number | No| Minimum number of fingers to trigger a swipe gesture. The value ranges from 1 to 10.<br>Default value: **1**|
| direction | SwipeDirection | No| Swipe direction.<br>Default value: **SwipeDirection.All**| | direction | [swipeDirection](#swipedirection)| No| Swipe direction.<br>Default value: **SwipeDirection.All**|
| speed | number | No| Minimum speed of the swipe gesture, in vp/s.<br>Default value: **100**| | speed | number | No| Minimum speed of the swipe gesture, in vp/s.<br>Default value: **100**|
## SwipeDirection ## SwipeDirection
...@@ -24,8 +24,8 @@ SwipeGesture(value?: { fingers?: number; direction?: SwipeDirection; speed?: num ...@@ -24,8 +24,8 @@ SwipeGesture(value?: { fingers?: number; direction?: SwipeDirection; speed?: num
| Name| Description| | Name| Description|
| -------- | -------- | | -------- | -------- |
| All | All directions.| | All | All directions.|
| Horizontal | Horizontal direction.| | Horizontal | Horizontal direction. The gesture event is triggered when the angle between the finger moving direction and the x-axis is less than 45 degrees.|
| Vertical | Vertical direction.| | Vertical | Vertical direction. The gesture event is triggered when the angle between the finger moving direction and the y-axis is less than 45 degrees.|
| None | Swiping disabled.| | None | Swiping disabled.|
...@@ -33,9 +33,8 @@ SwipeGesture(value?: { fingers?: number; direction?: SwipeDirection; speed?: num ...@@ -33,9 +33,8 @@ SwipeGesture(value?: { fingers?: number; direction?: SwipeDirection; speed?: num
| Name| Description| | Name| Description|
| -------- | -------- | | -------- | -------- |
| onAction(event:(event?: [GestureEvent](ts-gesture-settings.md)) =&gt; void) | Triggered when a swipe gesture is recognized.| | onAction(event:(event?: [GestureEvent](ts-gesture-settings.md#gestureevent)) =&gt; void) | Triggered when a swipe gesture is recognized.|
![en-us_image_0000001231374661](figures/en-us_image_0000001231374661.png)
## Example ## Example
```ts ```ts
...@@ -43,27 +42,31 @@ SwipeGesture(value?: { fingers?: number; direction?: SwipeDirection; speed?: num ...@@ -43,27 +42,31 @@ SwipeGesture(value?: { fingers?: number; direction?: SwipeDirection; speed?: num
@Entry @Entry
@Component @Component
struct SwipeGestureExample { struct SwipeGestureExample {
@State rotateAngle : number = 0 @State rotateAngle: number = 0;
@State speed : number = 1 @State speed: number = 1;
build() { build() {
Column() { Column() {
Text("SwipGesture speed : " + this.speed) Column() {
Text("SwipGesture angle : " + this.rotateAngle) Text("SwipeGesture speed\n" + this.speed)
} Text("SwipeGesture angle\n" + this.rotateAngle)
.position({x: 80, y: 200}) }
.border({width:2}) .border({ width: 3 })
.width(260).height(260) .width(300)
.rotate({x: 0, y: 0, z: 1, angle: this.rotateAngle}) .height(200)
.gesture( .margin(100)
SwipeGesture({fingers: 1, direction: SwipeDirection.Vertical}) .rotate({ angle: this.rotateAngle })
// The gesture event is triggered by swiping vertically with one finger.
.gesture(
SwipeGesture({ direction: SwipeDirection.Vertical })
.onAction((event: GestureEvent) => { .onAction((event: GestureEvent) => {
this.speed = event.speed this.speed = event.speed;
this.rotateAngle = event.angle this.rotateAngle = event.angle;
}) })
) )
}.width('100%')
} }
} }
``` ```
![en-us_image_0000001231374559](figures/en-us_image_0000001231374559.gif) ![en-us_image_0000001231374559.png](figures/en-us_image_0000001231374559.png)
...@@ -29,7 +29,7 @@ Creates a standard **\<Flex>** component. ...@@ -29,7 +29,7 @@ Creates a standard **\<Flex>** component.
| direction | [FlexDirection](ts-appendix-enums.md#flexdirection) | No | FlexDirection.Row | Direction in which child components are arranged in the **\<Flex>** component, that is, the direction of the main axis. | | direction | [FlexDirection](ts-appendix-enums.md#flexdirection) | No | FlexDirection.Row | Direction in which child components are arranged in the **\<Flex>** component, that is, the direction of the main axis. |
| wrap | [FlexWrap](ts-appendix-enums.md#flexwrap) | No | FlexWrap.NoWrap | Whether the **\<Flex>** component has a single line or multiple lines. | | wrap | [FlexWrap](ts-appendix-enums.md#flexwrap) | No | FlexWrap.NoWrap | Whether the **\<Flex>** component has a single line or multiple lines. |
| justifyContent | [FlexAlign](ts-appendix-enums.md#flexalign) | No | FlexAlign.Start | Alignment mode of the child components in the **\<Flex>** component along the main axis. | | justifyContent | [FlexAlign](ts-appendix-enums.md#flexalign) | No | FlexAlign.Start | Alignment mode of the child components in the **\<Flex>** component along the main axis. |
| alignItems | [ItemAlign](ts-appendix-enums.md#itemalign) | No | ItemAlign.Stretch | Alignment mode of the child components in the **\<Flex>** component along the cross axis. | | alignItems | [ItemAlign](ts-appendix-enums.md#itemalign) | No | ItemAlign.Start | Alignment mode of the child components in the **\<Flex>** component along the cross axis. |
| alignContent | [FlexAlign](ts-appendix-enums.md#flexalign) | No | FlexAlign.Start | Alignment mode of the child components in a multi-line **<Flex>** component along the cross axis. This parameter is valid only when **wrap** is set to **Wrap** or **WrapReverse**.| | alignContent | [FlexAlign](ts-appendix-enums.md#flexalign) | No | FlexAlign.Start | Alignment mode of the child components in a multi-line **<Flex>** component along the cross axis. This parameter is valid only when **wrap** is set to **Wrap** or **WrapReverse**.|
...@@ -240,9 +240,7 @@ struct FlexExample4 { ...@@ -240,9 +240,7 @@ struct FlexExample4 {
} }
``` ```
![en-us_image_0000001257138371](figures/en-us_image_0000001257138371.jpg) ![en-us_image_0000001174422904](figures/en-us_image_0000001174422904.jpg)
![en-us_image_0000001212378426](figures/en-us_image_0000001212378426.gif)
```ts ```ts
// xxx.ets // xxx.ets
......
...@@ -6,7 +6,7 @@ The **\<Scroll>** component scrolls the content when the layout size of a compon ...@@ -6,7 +6,7 @@ The **\<Scroll>** component scrolls the content when the layout size of a compon
> - This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. > - This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
> - When nesting a **\<List>** within this component, specify the width and height for the **\<List>** under scenarios where consistently high performance is required. If the width and height are not specified, this component will load all content of the **\<List>**. > - When nesting a **\<List>** within this component, specify the width and height for the **\<List>** under scenarios where consistently high performance is required. If the width and height are not specified, this component will load all content of the **\<List>**.
> - This component can scroll only when the size on the main axis is less than the content size. > - This component can scroll only when the size on the main axis is less than the content size.
> - The prerequisite for the component to rebound is that the component is scrolled. > - This component can produce a bounce effect only when there is more than one screen of content.
## Child Components ## Child Components
...@@ -24,11 +24,11 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the ...@@ -24,11 +24,11 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| Name | Type | Description | | Name | Type | Description |
| -------------- | ---------------------------------------- | --------- | | -------------- | ---------------------------------------- | --------- |
| scrollable | ScrollDirection | Scroll direction.<br>Default value: **ScrollDirection.Vertical**| | scrollable | [ScrollDirection](#scrolldirection) | Scroll direction.<br>Default value: **ScrollDirection.Vertical**|
| scrollBar | [BarState](ts-appendix-enums.md#barstate) | Scrollbar status.<br>Default value: **BarState.Off**| | scrollBar | [BarState](ts-appendix-enums.md#barstate) | Scrollbar status.<br>Default value: **BarState.Off**|
| scrollBarColor | string \| number \| Color | Color of the scrollbar.| | scrollBarColor | string \| number \| [Color](ts-appendix-enums.md#color) | Color of the scrollbar.|
| scrollBarWidth | string \| number | Width of the scrollbar.| | scrollBarWidth | string \| number | Width of the scrollbar.|
| edgeEffect | [EdgeEffect](ts-appendix-enums.md#edgeeffect) | Scroll effect. For details, see **EdgeEffect**.<br>Default value: **EdgeEffect.Spring**| | edgeEffect | [EdgeEffect](ts-appendix-enums.md#edgeeffect) | Scroll effect. For details, see **EdgeEffect**.<br>Default value: **EdgeEffect.None**|
## ScrollDirection ## ScrollDirection
| Name | Description | | Name | Description |
...@@ -36,7 +36,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the ...@@ -36,7 +36,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| Horizontal | Only horizontal scrolling is supported. | | Horizontal | Only horizontal scrolling is supported. |
| Vertical | Only vertical scrolling is supported. | | Vertical | Only vertical scrolling is supported. |
| None | Scrolling is disabled. | | None | Scrolling is disabled. |
| Free<sup>(deprecated) </sup> | Vertical or horizontal scrolling is supported.<br> This API is deprecated since API version 9.| | Free<sup>(deprecated) </sup> | Vertical or horizontal scrolling is supported.<br>This API is deprecated since API version 9. |
## Events ## Events
...@@ -104,7 +104,7 @@ Scrolls to the next or previous page. ...@@ -104,7 +104,7 @@ Scrolls to the next or previous page.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| --------- | ------- | ---- | ------------------------------ | | --------- | ------- | ---- | ------------------------------ |
| next | boolean | Yes | Whether to turn to the next page. The value **true** means to scroll to the next page, and **false** means to scroll to the previous page.| | next | boolean | Yes | Whether to turn to the next page. The value **true** means to scroll to the next page, and **false** means to scroll to the previous page.|
| direction<sup>(deprecated) </sup> | [Axis](ts-appendix-enums.md#axis) | No | Scrolling direction: horizontal or vertical.<br> This API is deprecated since API version 9. | | direction<sup>(deprecated) </sup> | [Axis](ts-appendix-enums.md#axis) | No | Scrolling direction: horizontal or vertical.<br>This API is deprecated since API version 9. |
### currentOffset ### currentOffset
...@@ -161,14 +161,15 @@ Scrolls by the specified amount. ...@@ -161,14 +161,15 @@ Scrolls by the specified amount.
## Example ## Example
### Example 1
```ts ```ts
// xxx.ets // xxx.ets
@Entry @Entry
@Component @Component
struct ScrollExample { struct ScrollExample {
scroller: Scroller = new Scroller() scroller: Scroller = new Scroller();
private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
build() { build() {
Stack({ alignContent: Alignment.TopStart }) { Stack({ alignContent: Alignment.TopStart }) {
...@@ -186,38 +187,39 @@ struct ScrollExample { ...@@ -186,38 +187,39 @@ struct ScrollExample {
}, item => item) }, item => item)
}.width('100%') }.width('100%')
} }
.scrollable(ScrollDirection.Vertical) .scrollable(ScrollDirection.Vertical) // The scrollbar scrolls in the vertical direction.
.scrollBar(BarState.On) .scrollBar(BarState.On) // The scrollbar is always displayed.
.scrollBarColor(Color.Gray) .scrollBarColor(Color.Gray) // Color of the scrollbar.
.scrollBarWidth(30) .scrollBarWidth(30) // Width of the scrollbar.
.edgeEffect(EdgeEffect.None)
.onScroll((xOffset: number, yOffset: number) => { .onScroll((xOffset: number, yOffset: number) => {
console.info(xOffset + ' ' + yOffset) console.info(xOffset + ' ' + yOffset);
}) })
.onScrollEdge((side: Edge) => { .onScrollEdge((side: Edge) => {
console.info('To the edge') console.info('To the edge');
}) })
.onScrollEnd(() => { .onScrollEnd(() => {
console.info('Scroll Stop') console.info('Scroll Stop');
}) })
Button('scroll 150') Button('scroll 150')
.onClick(() => { // Click to scroll down to 150.0 vp. .onClick(() => { // Click to scroll down to 150.0 vp.
this.scroller.scrollBy(0,150) this.scroller.scrollBy(0,150);
}) })
.margin({ top: 10, left: 20 }) .margin({ top: 10, left: 20 })
Button('scroll 100') Button('scroll 100')
.onClick(() => { // Click to scroll down by 100.0 vp. .onClick(() => { // Click to scroll down by 100.0 vp.
this.scroller.scrollTo({ xOffset: 0, yOffset: this.scroller.currentOffset().yOffset + 100 }) this.scroller.scrollTo({ xOffset: 0, yOffset: this.scroller.currentOffset().yOffset + 100 });
}) })
.margin({ top: 60, left: 20 }) .margin({ top: 60, left: 20 })
Button('back top') Button('back top')
.onClick(() => { // Click to go back to the top. .onClick(() => { // Click to go back to the top.
this.scroller.scrollEdge(Edge.Top) this.scroller.scrollEdge(Edge.Top);
}) })
.margin({ top: 110, left: 20 }) .margin({ top: 110, left: 20 })
Button('next page') Button('next page')
.onClick(() => { // Click to go to the next page. .onClick(() => { // Click to go to the next page.
this.scroller.scrollPage({ next: true }) this.scroller.scrollPage({ next: true });
}) })
.margin({ top: 170, left: 20 }) .margin({ top: 170, left: 20 })
}.width('100%').height('100%').backgroundColor(0xDCDCDC) }.width('100%').height('100%').backgroundColor(0xDCDCDC)
...@@ -227,14 +229,14 @@ struct ScrollExample { ...@@ -227,14 +229,14 @@ struct ScrollExample {
![en-us_image_0000001256978363](figures/en-us_image_0000001256978363.gif) ![en-us_image_0000001256978363](figures/en-us_image_0000001256978363.gif)
### Example 2
```ts ```ts
@Entry @Entry
@Component @Component
struct NestedScroll { struct NestedScroll {
@State listPosition: number = 0 // 0 indicates scrolling to the top of the list, 1 indicates scrolling to the center of the list, and 2 indicates scrolling to the bottom of the list. @State listPosition: number = 0; // 0 indicates scrolling to the top of the list, 1 indicates scrolling to the middle of the list, and 2 indicates scrolling to the bottom of the list.
private arr: number[] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] private arr: number[] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
private scroller: Scroller = new Scroller() private scroller: Scroller = new Scroller();
build() { build() {
Flex() { Flex() {
...@@ -255,18 +257,18 @@ struct NestedScroll { ...@@ -255,18 +257,18 @@ struct NestedScroll {
} }
.width("100%").height("50%").edgeEffect(EdgeEffect.None) .width("100%").height("50%").edgeEffect(EdgeEffect.None)
.onReachStart(() => { .onReachStart(() => {
this.listPosition = 0 this.listPosition = 0;
}) })
.onReachEnd(() => { .onReachEnd(() => {
this.listPosition = 2 this.listPosition = 2;
}) })
.onScrollBegin((dx: number, dy: number) => { .onScrollBegin((dx: number, dy: number) => {
if ((this.listPosition == 0 && dy >= 0) || (this.listPosition == 2 && dy <= 0)) { if ((this.listPosition == 0 && dy >= 0) || (this.listPosition == 2 && dy <= 0)) {
this.scroller.scrollBy(0, -dy) this.scroller.scrollBy(0, -dy);
return { dxRemain: dx, dyRemain: 0 } return { dxRemain: dx, dyRemain: 0 };
} }
this.listPosition = 1; this.listPosition = 1;
return { dxRemain: dx, dyRemain: dy } return { dxRemain: dx, dyRemain: dy };
}) })
Text("Scroll Area") Text("Scroll Area")
......
# Time Picker Dialog Box # Time Picker Dialog Box
A time picker dialog box is a dialog box that allows users to select a time from the given range, which is from 00:00 to 23:59 by default. A time picker dialog box is a dialog box that allows users to select a time from the 24-hour range.
> **NOTE** > **NOTE**
> >
> The APIs of this module are supported since API version 9. Updates will be marked with a superscript to indicate their earliest API version. > The APIs of this module are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
## Required Permissions
None
## TimePickerDialog.show ## TimePickerDialog.show
...@@ -18,71 +13,63 @@ show(options?: TimePickerDialogOptions) ...@@ -18,71 +13,63 @@ show(options?: TimePickerDialogOptions)
Shows a time picker dialog box. Shows a time picker dialog box.
- TimePickerDialogOptions - TimePickerDialogOptions
| Name| Type| Mandatory| Default Value| Description|
| -------- | -------- | -------- | -------- | -------- | | Name| Type| Mandatory| Description|
| selected | Date | No| Current system time| Time of the selected item.| | -------- | -------- | -------- | -------- |
| useMilitaryTime | boolean | No| false | Whether to display time in 24-hour format.| | selected | Date | No| Selected time.<br>Default value: current system time|
| onAccept | (value: [TimePickerResult](ts-basic-components-timepicker.md#TimePickerResult)) => void | No| - | Callback invoked when the OK button in the dialog box is clicked.| | useMilitaryTime | boolean | No| Whether to display time in 24-hour format. The 12-hour format is used by default.<br>Default value: **false**|
| onCancel | () => void | No| - | Callback invoked when the Cancel button in the dialog box is clicked.| | onAccept | (value: [TimePickerResult](ts-basic-components-timepicker.md#TimePickerResult)) => void | No| Callback invoked when the OK button in the dialog box is clicked.|
| onChange | (value: [TimePickerResult](ts-basic-components-timepicker.md#TimePickerResult)) => void | No| - | Callback invoked when the selected item in the picker changes.| | onCancel | () => void | No| Callback invoked when the Cancel button in the dialog box is clicked.|
| onChange | (value: [TimePickerResult](ts-basic-components-timepicker.md#TimePickerResult)) => void | No| Callback invoked when the selected time changes.|
## Example ## Example
### Time Picker Sample Code (24-Hour Clock)
```ts ```ts
// xxx.ets // xxx.ets
@Entry @Entry
@Component @Component
struct TimePickerDialogExample01 { struct TimePickerDialogExample {
@State isUseMilitaryTime: boolean = true private selectTime: Date = new Date('2020-12-25T08:30:00')
build() { build() {
Flex({direction: FlexDirection.Column, alignItems: ItemAlign.Center, Column() {
justifyContent: FlexAlign.Center }) { Button ("TimePickerDialog 12-hour format")
Button("TimePickerDialog").onClick(() => { .margin(20)
TimePickerDialog.show({ .onClick(() => {
useMilitaryTime: this.isUseMilitaryTime, TimePickerDialog.show({
onAccept: (value: TimePickerResult) => { selected: this.selectTime,
console.info("TimePickerDialog:onAccept()" + JSON.stringify(value)) onAccept: (value: TimePickerResult) => {
}, //Set selectTime to the time when the OK button is clicked. In this way, when the dialog box is displayed again, the selected time is the time when the operation was confirmed last time.
onCancel: () => { this.selectTime.setHours(value.hour, value.minute)
console.info("TimePickerDialog:onCancel()") console.info("TimePickerDialog:onAccept()" + JSON.stringify(value));
}, },
onChange: (value: TimePickerResult) => { onCancel: () => {
console.info("TimePickerDialog:onChange()" + JSON.stringify(value)) console.info("TimePickerDialog:onCancel()");
} },
onChange: (value: TimePickerResult) => {
console.info("TimePickerDialog:onChange()" + JSON.stringify(value));
}
})
}) })
}) Button ("TimePickerDialog 24-hour format")
} .margin(20)
} .onClick(() => {
} TimePickerDialog.show({
``` selected: this.selectTime,
### Time Picker Sample Code (12-Hour Clock) useMilitaryTime: true,
```ts onAccept: (value: TimePickerResult) => {
// xxx.ets this.selectTime.setHours(value.hour, value.minute)
@Entry console.info("TimePickerDialog:onAccept()" + JSON.stringify(value));
@Component },
struct TimePickerDialogExample02 { onCancel: () => {
@State isUseMilitaryTime: boolean = false console.info("TimePickerDialog:onCancel()");
},
build() { onChange: (value: TimePickerResult) => {
Flex({direction: FlexDirection.Column, alignItems: ItemAlign.Center, console.info("TimePickerDialog:onChange()" + JSON.stringify(value));
justifyContent: FlexAlign.Center }) { }
Button("TimePickerDialog").onClick(() => { })
TimePickerDialog.show({
useMilitaryTime: this.isUseMilitaryTime,
onAccept: (value: TimePickerResult) => {
console.info("TimePickerDialog:onAccept()" + JSON.stringify(value))
},
onCancel: () => {
console.info("TimePickerDialog:onCancel()")
},
onChange: (value: TimePickerResult) => {
console.info("TimePickerDialog:onChange()" + JSON.stringify(value))
}
}) })
}) }.width('100%')
}
} }
} }
``` ```
...@@ -77,7 +77,7 @@ Sends a touch event. ...@@ -77,7 +77,7 @@ Sends a touch event.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ----- | ----------- | ---- | ------------------------------------------------------------ | | ----- | ----------- | ---- | ------------------------------------------------------------ |
| event | TouchObject | Yes | Location where a touch event is triggered. For details, see [TouchEvent](ts-universal-events-touch.md#touchevent).| | event | [TouchObject](ts-universal-events-touch.md#touchobject) | Yes | Location where a touch event is triggered. For details, see [TouchEvent](ts-universal-events-touch.md#touchevent).|
**Return value** **Return value**
...@@ -95,7 +95,7 @@ Sends a key event. ...@@ -95,7 +95,7 @@ Sends a key event.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ----- | -------- | ---- | ------------------------------------------------------------ | | ----- | -------- | ---- | ------------------------------------------------------------ |
| event | KeyEvent | Yes | Key event. For details, see [KeyEvent](ts-universal-events-key.md#keyevent).| | event | [KeyEvent](ts-universal-events-key.md#keyevent) | Yes | Key event. For details, see [KeyEvent](ts-universal-events-key.md#keyevent).|
**Return value** **Return value**
...@@ -113,7 +113,7 @@ Sends a mouse event. ...@@ -113,7 +113,7 @@ Sends a mouse event.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ----- | ---------- | ---- | --------------------------------------- | | ----- | ---------- | ---- | --------------------------------------- |
| event | MouseEvent | Yes | Mouse event. For details, see [MouseEvent](ts-universal-mouse-key.md#mouseevent).| | event | [MouseEvent](ts-universal-mouse-key.md#mouseevent) | Yes | Mouse event. For details, see [MouseEvent](ts-universal-mouse-key.md#mouseevent).|
**Return value** **Return value**
...@@ -132,6 +132,7 @@ class Utils { ...@@ -132,6 +132,7 @@ class Utils {
static rect_bottom; static rect_bottom;
static rect_value; static rect_value;
// Obtain the coordinates of the rectangular area occupied by the component.
static getComponentRect(key) { static getComponentRect(key) {
let strJson = getInspectorByKey(key); let strJson = getInspectorByKey(key);
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
...@@ -171,7 +172,7 @@ struct IdExample { ...@@ -171,7 +172,7 @@ struct IdExample {
console.info(getInspectorTree()) console.info(getInspectorTree())
this.text = "Button 'click to start' is clicked" this.text = "Button 'click to start' is clicked"
setTimeout(() => { setTimeout(() => {
sendEventByKey("longClick", 11, "") sendEventByKey("longClick", 11, "") // Send a long-click event to the component whose ID is "longClick".
}, 2000) }, 2000)
}).id('click') }).id('click')
...@@ -183,18 +184,18 @@ struct IdExample { ...@@ -183,18 +184,18 @@ struct IdExample {
console.info('long clicked') console.info('long clicked')
this.text = "Button 'longClick' is longclicked" this.text = "Button 'longClick' is longclicked"
setTimeout(() => { setTimeout(() => {
let rect = Utils.getComponentRect('onTouch') let rect = Utils.getComponentRect('onTouch') // Obtain the coordinates of the rectangular area occupied by the component whose ID is "onTouch".
let touchPoint: TouchObject = { let touchPoint: TouchObject = {
id: 1, id: 1,
x: rect.left + (rect.right - rect.left) / 2, x: rect.left + (rect.right - rect.left) / 2, // X coordinate of the component center.
y: rect.top + (rect.bottom - rect.top) / 2, y: rect.top + (rect.bottom - rect.top) / 2, // Y coordinate of the component center.
type: TouchType.Down, type: TouchType.Down,
screenX: rect.left + (rect.right - rect.left) / 2, screenX: rect.left + (rect.right - rect.left) / 2, // X coordinate of the component center.
screenY: rect.left + (rect.right - rect.left) / 2, screenY: rect.left + (rect.right - rect.left) / 2, // Y coordinate of the component center.
} }
sendTouchEvent(touchPoint) sendTouchEvent(touchPoint) // Send a touch event.
touchPoint.type = TouchType.Up touchPoint.type = TouchType.Up
sendTouchEvent(touchPoint) sendTouchEvent(touchPoint) // Send a touch event.
}, 2000) }, 2000)
})).id('longClick') })).id('longClick')
...@@ -205,14 +206,14 @@ struct IdExample { ...@@ -205,14 +206,14 @@ struct IdExample {
console.info('onTouch is clicked') console.info('onTouch is clicked')
this.text = "Button 'onTouch' is clicked" this.text = "Button 'onTouch' is clicked"
setTimeout(() => { setTimeout(() => {
let rect = Utils.getComponentRect('onMouse') let rect = Utils.getComponentRect('onMouse') // Obtain the coordinates of the rectangular area occupied by the component whose ID is "onMouse".
let mouseEvent: MouseEvent = { let mouseEvent: MouseEvent = {
button: MouseButton.Left, button: MouseButton.Left,
action: MouseAction.Press, action: MouseAction.Press,
x: rect.left + (rect.right - rect.left) / 2, x: rect.left + (rect.right - rect.left) / 2, // X coordinate of the component center.
y: rect.top + (rect.bottom - rect.top) / 2, y: rect.top + (rect.bottom - rect.top) / 2, // Y coordinate of the component center.
screenX: rect.left + (rect.right - rect.left) / 2, screenX: rect.left + (rect.right - rect.left) / 2, // X coordinate of the component center.
screenY: rect.top + (rect.bottom - rect.top) / 2, screenY: rect.top + (rect.bottom - rect.top) / 2, // Y coordinate of the component center.
timestamp: 1, timestamp: 1,
target: { target: {
area: { area: {
...@@ -230,7 +231,7 @@ struct IdExample { ...@@ -230,7 +231,7 @@ struct IdExample {
}, },
source: SourceType.Mouse source: SourceType.Mouse
} }
sendMouseEvent(mouseEvent) sendMouseEvent(mouseEvent) // Send a mouse event.
}, 2000) }, 2000)
}).id('onTouch') }).id('onTouch')
...@@ -250,7 +251,7 @@ struct IdExample { ...@@ -250,7 +251,7 @@ struct IdExample {
metaKey: 0, metaKey: 0,
timestamp: 0 timestamp: 0
} }
sendKeyEvent(keyEvent) sendKeyEvent(keyEvent) // Send a key event.
}, 2000) }, 2000)
}).id('onMouse') }).id('onMouse')
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
@Entry @Entry
@Component @Component
struct FlexExample { struct FlexExample {
build() { build() {
Column({ space: 5 }) { Column({ space: 5 }) {
Text('flexBasis').fontSize(9).fontColor(0xCCCCCC).width('90%') Text('flexBasis').fontSize(9).fontColor(0xCCCCCC).width('90%')
...@@ -31,11 +30,18 @@ struct FlexExample { ...@@ -31,11 +30,18 @@ struct FlexExample {
// The value of flexBasis() can be 'auto' or a number, which is equivalent to .width()/.height(). // The value of flexBasis() can be 'auto' or a number, which is equivalent to .width()/.height().
Flex() { Flex() {
Text('flexBasis(100)') Text('flexBasis(100)')
.flexBasis('100').height(100).lineHeight(70) .flexBasis('100')
.backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) .height(100)
.lineHeight(70)
.backgroundColor(0xF5DEB3)
.textAlign(TextAlign.Center)
Text('flexBasis("auto")') Text('flexBasis("auto")')
.flexBasis('auto').width('60%').height(100).lineHeight(70) .flexBasis('auto')
.backgroundColor(0xD2B48C).textAlign(TextAlign.Center) .width('60%')
.height(100)
.lineHeight(70)
.backgroundColor(0xD2B48C)
.textAlign(TextAlign.Center)
}.width('90%').height(120).padding(10).backgroundColor(0xAFEEEE) }.width('90%').height(120).padding(10).backgroundColor(0xAFEEEE)
Text('flexGrow').fontSize(9).fontColor(0xCCCCCC).width('90%') Text('flexGrow').fontSize(9).fontColor(0xCCCCCC).width('90%')
...@@ -43,11 +49,17 @@ struct FlexExample { ...@@ -43,11 +49,17 @@ struct FlexExample {
// flexGrow() specifies the percentage of the remaining space allocated to the component. // flexGrow() specifies the percentage of the remaining space allocated to the component.
Flex() { Flex() {
Text('flexGrow(2)') Text('flexGrow(2)')
.flexGrow(2).height(100).lineHeight(70) .flexGrow(2)
.backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) .height(100)
.lineHeight(70)
.backgroundColor(0xF5DEB3)
.textAlign(TextAlign.Center)
Text('flexGrow(1)') Text('flexGrow(1)')
.flexGrow(1).height(100).lineHeight(70) .flexGrow(1)
.backgroundColor(0xD2B48C).textAlign(TextAlign.Center) .height(100)
.lineHeight(70)
.backgroundColor(0xD2B48C)
.textAlign(TextAlign.Center)
}.width('90%').height(120).padding(10).backgroundColor(0xAFEEEE) }.width('90%').height(120).padding(10).backgroundColor(0xAFEEEE)
Text('flexShrink').fontSize(9).fontColor(0xCCCCCC).width('90%') Text('flexShrink').fontSize(9).fontColor(0xCCCCCC).width('90%')
...@@ -55,13 +67,25 @@ struct FlexExample { ...@@ -55,13 +67,25 @@ struct FlexExample {
// The ratio of text1 is 0, and the default values of other parameters are 1. If the components cannot be completely displayed, the last two components are shrunk proportionally. The first component is not shrunk. // The ratio of text1 is 0, and the default values of other parameters are 1. If the components cannot be completely displayed, the last two components are shrunk proportionally. The first component is not shrunk.
Flex({ direction: FlexDirection.Row }) { Flex({ direction: FlexDirection.Row }) {
Text('flexShrink(0)') Text('flexShrink(0)')
.flexShrink(0).width('50%').height(100).lineHeight(70) .flexShrink(0)
.backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) .width('50%')
.height(100)
.lineHeight(70)
.backgroundColor(0xF5DEB3)
.textAlign(TextAlign.Center)
Text('no flexShrink') Text('no flexShrink')
.width('40%').height(100).lineHeight(70).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) .width('40%')
.height(100)
.lineHeight(70)
.backgroundColor(0xD2B48C)
.textAlign(TextAlign.Center)
Text('flexShrink(2)') Text('flexShrink(2)')
.flexShrink(2).width('40%').height(100) .lineHeight(70) .flexShrink(2)
.backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) .width('40%')
.height(100)
.lineHeight(70)
.backgroundColor(0xF5DEB3)
.textAlign(TextAlign.Center)
}.width('90%').height(120).padding(10).backgroundColor(0xAFEEEE) }.width('90%').height(120).padding(10).backgroundColor(0xAFEEEE)
Text('alignSelf').fontSize(9).fontColor(0xCCCCCC).width('90%') Text('alignSelf').fontSize(9).fontColor(0xCCCCCC).width('90%')
...@@ -70,8 +94,12 @@ struct FlexExample { ...@@ -70,8 +94,12 @@ struct FlexExample {
Text('no alignSelf,height:80').width('33%').height(80) Text('no alignSelf,height:80').width('33%').height(80)
.backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) .backgroundColor(0xF5DEB3).textAlign(TextAlign.Center)
Text('alignSelf stretch') Text('alignSelf stretch')
.alignSelf(ItemAlign.Stretch).width('33%').height(80).lineHeight(70) .alignSelf(ItemAlign.Stretch)
.backgroundColor(0xD2B48C).textAlign(TextAlign.Center) .width('33%')
.height(80)
.lineHeight(70)
.backgroundColor(0xD2B48C)
.textAlign(TextAlign.Center)
Text('no alignSelf,height:100').width('34%').height(100) Text('no alignSelf,height:100').width('34%').height(100)
.backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) .backgroundColor(0xF5DEB3).textAlign(TextAlign.Center)
}.width('90%').height(120).padding(10).backgroundColor(0xAFEEEE) }.width('90%').height(120).padding(10).backgroundColor(0xAFEEEE)
......
...@@ -12,7 +12,7 @@ You can set the opacity of a component. ...@@ -12,7 +12,7 @@ You can set the opacity of a component.
| Name | Type | Description | | Name | Type | Description |
| ------- | ---------------------------------------- | ---------------------------------------- | | ------- | ---------------------------------------- | ---------------------------------------- |
| opacity | number \| [Resource](ts-types.md#resource) | Opacity of a component. The value ranges from **0** to **1**. The value **1** means opaque, and **0** means completely transparent.<br>Default value: **1**| | opacity | number \| [Resource](ts-types.md#resource) | Opacity of the component. The value ranges from 0 to 1. The value **1** means opaque, and **0** means completely transparent. When being completely transparent, the component is hidden, but still takes up space in the layout.<br>**NOTE**<br>A child component can inherit this attribute of its parent component. Default value: **1**|
## Example ## Example
...@@ -30,6 +30,10 @@ struct OpacityExample { ...@@ -30,6 +30,10 @@ struct OpacityExample {
Text().width('90%').height(50).opacity(0.7).backgroundColor(0xAFEEEE) Text().width('90%').height(50).opacity(0.7).backgroundColor(0xAFEEEE)
Text('opacity(0.4)').fontSize(9).width('90%').fontColor(0xCCCCCC) Text('opacity(0.4)').fontSize(9).width('90%').fontColor(0xCCCCCC)
Text().width('90%').height(50).opacity(0.4).backgroundColor(0xAFEEEE) Text().width('90%').height(50).opacity(0.4).backgroundColor(0xAFEEEE)
Text('opacity(0.1)').fontSize(9).width('90%').fontColor(0xCCCCCC)
Text().width('90%').height(50).opacity(0.1).backgroundColor(0xAFEEEE)
Text('opacity(0)').fontSize(9).width('90%').fontColor(0xCCCCCC)
Text().width('90%').height(50).opacity(0).backgroundColor(0xAFEEEE)
} }
.width('100%') .width('100%')
.padding({ top: 5 }) .padding({ top: 5 })
...@@ -37,4 +41,4 @@ struct OpacityExample { ...@@ -37,4 +41,4 @@ struct OpacityExample {
} }
``` ```
![en-us_image_0000001256858385](figures/en-us_image_0000001256858385.gif) ![opacity.png](figures/opacity.png)
# Visible Area Change Event # Visible Area Change Event
The visible area change event of a component refers to the change in the visual portion of a component on the screen. It can be used to determine whether the component is completely or partially displayed on the screen. It is usually applicable to scenarios such as advertisement exposure tracing. The visible area change event of a component refers to the change in the visual portion of the component on the screen. It can be used to determine whether the component is completely or partially displayed on the screen. It is usually applicable to scenarios such as advertisement exposure tracing.
> **NOTE** > **NOTE**
> >
...@@ -23,8 +23,8 @@ The visible area change event of a component refers to the change in the visual ...@@ -23,8 +23,8 @@ The visible area change event of a component refers to the change in the visual
struct ScrollExample { struct ScrollExample {
scroller: Scroller = new Scroller() scroller: Scroller = new Scroller()
private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
@State testTextStr: string = "test" @State testTextStr: string = 'test'
@State testRowStr: string = "test" @State testRowStr: string = 'test'
build() { build() {
Column() { Column() {
...@@ -46,22 +46,22 @@ struct ScrollExample { ...@@ -46,22 +46,22 @@ struct ScrollExample {
.height(200) .height(200)
.margin({ top: 50, bottom: 20 }) .margin({ top: 50, bottom: 20 })
.backgroundColor(Color.Green) .backgroundColor(Color.Green)
// Set ratios to [0.0, 1.0] to invoke the callback when the component is fully visible or invisible on screen. // Set ratios to [0.0, 1.0] to invoke the callback when the component is fully visible or invisible on screen.
.onVisibleAreaChange([0.0, 1.0], (isVisible: boolean, currentRatio: number) => { .onVisibleAreaChange([0.0, 1.0], (isVisible: boolean, currentRatio: number) => {
console.info("Test Text isVisible: " + isVisible + ", currentRatio:" + currentRatio) console.info('Test Text isVisible: ' + isVisible + ', currentRatio:' + currentRatio)
if (isVisible && currentRatio >= 1.0) { if (isVisible && currentRatio >= 1.0) {
console.info("Test Text is fully visible. currentRatio:" + currentRatio) console.info('Test Text is fully visible. currentRatio:' + currentRatio)
this.testTextStr = "Test Text is fully visible" this.testTextStr = 'Test Text is fully visible'
} }
if (!isVisible && currentRatio <= 0.0) { if (!isVisible && currentRatio <= 0.0) {
console.info("Test Text is completely invisible.") console.info('Test Text is completely invisible.')
this.testTextStr = "Test Text is completely invisible" this.testTextStr = 'Test Text is completely invisible'
} }
}) })
Row() { Row() {
Text("Test Row Visible Change") Text('Test Row Visible Change')
.fontSize(20) .fontSize(20)
.margin({ bottom: 20 }) .margin({ bottom: 20 })
...@@ -69,15 +69,15 @@ struct ScrollExample { ...@@ -69,15 +69,15 @@ struct ScrollExample {
.height(200) .height(200)
.backgroundColor(Color.Yellow) .backgroundColor(Color.Yellow)
.onVisibleAreaChange([0.0, 1.0], (isVisible: boolean, currentRatio: number) => { .onVisibleAreaChange([0.0, 1.0], (isVisible: boolean, currentRatio: number) => {
console.info("Test Row isVisible:" + isVisible + ", currentRatio:" + currentRatio) console.info('Test Row isVisible:' + isVisible + ', currentRatio:' + currentRatio)
if (isVisible && currentRatio >= 1.0) { if (isVisible && currentRatio >= 1.0) {
console.info("Test Row is fully visible.") console.info('Test Row is fully visible.')
this.testRowStr = "Test Row is fully visible" this.testRowStr = 'Test Row is fully visible'
} }
if (!isVisible && currentRatio <= 0.0) { if (!isVisible && currentRatio <= 0.0) {
console.info("Test Row is is completely invisible.") console.info('Test Row is is completely invisible.')
this.testRowStr = "Test Row is is completely invisible" this.testRowStr = 'Test Row is is completely invisible'
} }
}) })
......
# Adding Title and Paragraph Text # Adding Title and Paragraph Text
The **\<text>** component is most commonly used to display text in title and paragraph areas. You can set attributes and styles for a **\<text>** component and add the text to be displayed between the **\<text>** and **\</text>** tags. For details about the attributes and styles, see [text](../reference/arkui-js/js-components-basic-text.md). The following is an example of adding title and paragraph text on a page:
The &lt;text&gt; component is most commonly used to display text in title and paragraph areas. You can set attributes and styles for a &lt;text&gt; component and add the text to be displayed between the &lt;text&gt; and &lt;/text&gt; tags. For details about the attributes and styles, see [text](../reference/arkui-js/js-components-basic-text.md). The following is an example of adding title and paragraph text on a page:
```html ```html
...@@ -26,8 +25,10 @@ The &lt;text&gt; component is most commonly used to display text in title and pa ...@@ -26,8 +25,10 @@ The &lt;text&gt; component is most commonly used to display text in title and pa
font-size: 50px; font-size: 50px;
margin-top: 40px; margin-top: 40px;
margin-bottom: 20px; margin-bottom: 20px;
font-weight: 700;
} }
.paragraph-text { .paragraph-text {
width: 95%;
color: #000000; color: #000000;
font-size: 35px; font-size: 35px;
line-height: 60px; line-height: 60px;
...@@ -39,9 +40,11 @@ The &lt;text&gt; component is most commonly used to display text in title and pa ...@@ -39,9 +40,11 @@ The &lt;text&gt; component is most commonly used to display text in title and pa
// xxx.js // xxx.js
export default { export default {
data: { data: {
headTitle: 'Capture the Beauty in This Moment', headTitle: 'Capture the Beauty in Moment',
paragraphFirst: 'Capture the beauty of light during the transition and fusion of ice and water. At the instant of movement and stillness, softness and rigidity, force and beauty, condensing moving moments.', paragraphFirst: 'Capture the beauty of light during the transition and fusion of ice and water. At the instant of movement and stillness, softness and rigidity, force and beauty, condensing moving moments.',
paragraphSecond: 'Reflecting the purity of nature, the innovative design upgrades your visual entertainment and ergonomic comfort. Effortlessly capture what you see and let it speak for what you feel.', paragraphSecond: 'Reflecting the purity of nature, the innovative design upgrades your visual entertainment and ergonomic comfort. Effortlessly capture what you see and let it speak for what you feel.',
}, },
} }
``` ```
![en-us_image_0000001118642600](figures/en-us_image_0000001118642600.PNG)
# &lt;grid-container&gt; Development # Grid Layout
The **&lt;grid-container&gt;** component is the root container of the grid layout. Within the root container, you can use **&lt;grid-row&gt;** and **&lt;grid-col&gt;** for the grid layout. For details, see [grid-container](../reference/arkui-js/js-components-grid-container.md). The **\<grid-container>** component is the root container of the grid layout. Within the root container, you can use **\<grid-row>** and **\<grid-col>** for the grid layout. For details, see [Grid-container](../reference/arkui-js/js-components-grid-container.md).
## Creating a &lt;grid-container&gt; Component ## Creating a \<grid-container> Component
Create a **&lt;grid-container&gt;** component in the .hml file under **pages/index** and add a [**&lt;grid-row&gt;**](../reference/arkui-js/js-components-grid-row.md) child component. Create a **\<grid-container>** component in the .hml file under **pages/index** and add a [\<Grid-row>](../reference/arkui-js/js-components-grid-row.md) child component.
```html ```html
...@@ -37,12 +37,12 @@ Create a **&lt;grid-container&gt;** component in the .hml file under **pages/ind ...@@ -37,12 +37,12 @@ Create a **&lt;grid-container&gt;** component in the .hml file under **pages/ind
> **NOTE** > **NOTE**
> >
> **&lt;grid-container&gt;** supports only **&lt;grid-row&gt;** as a child component. > **\<grid-container>** supports only **\<grid-row>** as a child component.
## Methods ## Methods
Click the **&lt;grid-container&gt;** component to call the **getColumns**, **getColumnWidth**, and **getGutterWidth** methods to return the number of columns in the grid container, and column width and gutter width of the grid container. Press and hold the component to call the **getSizeType** method to return the size-responsive type of the grid container (**xs**|**sm**|**md**|**lg**). Touch the **\<grid-container>** component to call the **getColumns**, **getColumnWidth**, and **getGutterWidth** methods to return the number of columns in the grid container, and column width and gutter width of the grid container. Press and hold the component to call the **getSizeType** method to return the size-responsive type of the grid container (**xs**|**sm**|**md**|**lg**).
```html ```html
...@@ -109,9 +109,9 @@ export default { ...@@ -109,9 +109,9 @@ export default {
![en-us_image_0000001231843088](figures/en-us_image_0000001231843088.gif) ![en-us_image_0000001231843088](figures/en-us_image_0000001231843088.gif)
## Adding &lt;grid-col&gt; ## Adding \<grid-col>
After adding a **&lt;grid-row&gt;** child component to **&lt;grid-container&gt;**, add a **&lt;grid-col&gt;** child component to **&lt;grid-row&gt;** to form a layout. After adding a **\<grid-row>** child component to **\<grid-container>**, add a **\<grid-col>** child component to **\<grid-row>** to form a layout.
```html ```html
...@@ -168,7 +168,7 @@ text{ ...@@ -168,7 +168,7 @@ text{
> **NOTE** > **NOTE**
> >
> **&lt;grid-row&gt;** supports only **&lt;grid-col&gt;** as a child component. You can add content only to **&lt;grid-col&gt;**. > **\<grid-row>** supports only **\<grid-col>** as a child component. You can add content only to **\<grid-col>**.
## Example Scenario ## Example Scenario
...@@ -243,4 +243,4 @@ export default { ...@@ -243,4 +243,4 @@ export default {
``` ```
![en-us_image_0000001276003501](figures/en-us_image_0000001276003501.gif) ![en-us_image_0000001276003501](figures/en-us_image_0000001276003501.gif)
\ No newline at end of file
# OffscreenCanvasRenderingContext2D # OffscreenCanvasRenderingContext2D
**OffscreenCanvasRenderingContext2D** allows you to draw rectangles, text, images, and other objects on an offscreen canvas. For details, see [OffscreenCanvasRenderingContext2D](../reference/arkui-js/js-offscreencanvasrenderingcontext2d.md). **OffscreenCanvasRenderingContext2D** allows you to draw rectangles, text, images, and other objects on an offscreen canvas, which is a new buffer created by the GPU outside of the current buffer. For details, see [OffscreenCanvasRenderingContext2D](../reference/arkui-js/js-offscreencanvasrenderingcontext2d.md).
Create an **OffscreenCanvas** and then a **getContext2d** object on the canvas. Then, create an image and set the **filter** attribute to change the image style. In the following example, you first create an offscreen canvas, and then create a **getContext2d** object on the canvas, which is an image, and finally set the **filter** attribute for the image.
```html ```html
<!-- xxx.hml --> <!-- xxx.hml -->
...@@ -86,7 +86,7 @@ export default { ...@@ -86,7 +86,7 @@ export default {
## Determining the Position ## Determining the Position
Use **isPointInPath** and **isPointInStroke** to determine and show whether a coordinate is within the path area and whether a coordinate is on the edge of the path. Use **isPointInPath** to determine whether a coordinate is within the path area and use **isPointInStroke** to determine whether a coordinate is on the edge of the path.
```html ```html
...@@ -181,4 +181,4 @@ export default { ...@@ -181,4 +181,4 @@ export default {
} }
``` ```
![en-us_image_0000001276003489](figures/en-us_image_0000001276003489.gif) ![en-us_image_0000001178084014](figures/en-us_image_0000001178084014.gif)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册