HarmonyOS 图片预览,通过小图看大图的组件或三方库?

如题:HarmonyOS 图片预览,通过小图看大图的组件或三方库?

阅读 399
1 个回答

示例参考如下:

ImageGesture.ets

@Component
export struct ImageGesture {
  @State visible: Visibility = Visibility.None
  build() {
    Stack() {
      Row() {
        Column() {
          Image($r('app.media.icon'))
            .width(100)
            .height(100)
            .onClick(() => {
              console.log("hit me!")
              if ( this.visible== Visibility.Visible) {
                this.visible = Visibility.None
              } else {
                this.visible = Visibility.Visible
              }
            })
        }
        .width('100%')
        .justifyContent(FlexAlign.Center)
        .alignItems(HorizontalAlign.Center)
      }
      .height('100%')

      Text('')
        .onClick(() => {
          if (this.visible == Visibility.Visible) {
            this.visible = Visibility.None
          } else {
            this.visible = Visibility.Visible
          }
        })
        .width('100%')
        .height('100%')
        .backgroundColor(0x000000)
        .visibility(this.visible)

      Column() {
        Image($r('app.media.icon'))
          .width(300)
          .height(300)
          .draggable(false)
          .visibility(this.visible)
      }
    }
  }
}

Index.ets

import {ImageGesture} from './ImageGesture'
@Entry
@Component
struct Index {
  build() {
    Column(){
      ImageGesture()
    }
    .height('100%')
  }
}

手指缩放参考一下链接:https://gitee.com/harmonyos-cases/cases/blob/master/CommonAppDevelopment/feature/imageviewer/README.md

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进