@Entry @Component struct Index1 { build() { Column() { Image($r('app.media.startIcon')) .width(20) .height(20) .onClick(() => { this.getUIContext().getPromptAction().showToast({ message: '已触发' }); }) .responseRegion({ width: 200, height: 200 }); } .width('100%') .height('100%') .backgroundColor(0xDCDCDC) .padding({ top: 5 }); } }
@Entry @Component struct Index2 { build() { Column() { Row() { Image($r('app.media.startIcon')) .width(20) .height(20) .margin({ bottom: 200 }); // 通过设置内边距扩大实际点击区域 } .onClick(() => { this.getUIContext().getPromptAction().showToast({ message: '已触发' }); }); } .width('100%') .height('100%') .backgroundColor(0xDCDCDC) .padding({ top: 5 }); } }