Harmony Next -- 图片选择库:宫格展示、全屏预览

hm_image_select_view

OpenHarmony三方库中心仓:https://ohpm.openharmony.cn/#/cn/detail/image_select_view

介绍

Harmony Next 图片选择库,可设置最大选择数量、单行显示数量、横向竖向间隔;点击图片后全屏预览

软件架构

Harmony next版本,兼容API12

效果图

安装教程
  1. ohpm install image_select_view
使用说明
  1. 引入仓库

基础使用:

复制代码
import { CommonTitleBar, TitleType } from '@ohos/commonTitleBar'
import { ImageSelectView } from '@ohos/imageSelectView';

@Component
export struct ImagePage {
  build() {
    NavDestination() {
      Scroll() {
        Column() {
          CommonTitleBar({
            leftType: TitleType.NONE,
            centerType: TitleType.TEXT,
            centerText: "图片选择器",
          })

          Text("选择图片、全屏预览")

          ImageSelectView({
            maxSelect: 9, // 最大选择数
            columns: 4, // 一行显示数
            gutterX: 10, // 横向间隔
            gutterY: 10, // 竖向间隔
            onImageListChange: (images) => {
              console.log("PZR_TAG", "Images:" + JSON.stringify(images))
            }
          })
            .margin({
              left: 10,
              right: 10,
            })
            
           Text("展示图片、全屏预览")

          ImageSelectView({
            columns: 4, // 一行显示数
            gutterX: 10, // 横向间隔
            gutterY: 10, // 竖向间隔
            isPreview: true, // 仅作为展示和预览使用,常用于详情页
            imageList: [
              "https://hm-pzr.obs.cn-east-3.myhuaweicloud.com/hm/image_select1.png",
              "https://img-blog.csdnimg.cn/img_convert/fce61a2a73dd039a254ad37d546ed373.png",
              "https://hm-pzr.obs.cn-east-3.myhuaweicloud.com/hm/image_select1.png",
              "https://img-blog.csdnimg.cn/img_convert/fce61a2a73dd039a254ad37d546ed373.png",
              "https://hm-pzr.obs.cn-east-3.myhuaweicloud.com/hm/image_select1.png",
              "https://hm-pzr.obs.cn-east-3.myhuaweicloud.com/hm/image_select1.png",
              "https://hm-pzr.obs.cn-east-3.myhuaweicloud.com/hm/image_select1.png",
              "https://hm-pzr.obs.cn-east-3.myhuaweicloud.com/hm/image_select1.png",],
          })
            .margin({
              left: 10,
              right: 10,
            })
        }
      }
    }
    .backgroundColor($r('sys.color.comp_background_focus'))
    .hideTitleBar(true)
  }
}
相关推荐
xianjixiance_3 小时前
Flutter跨平台三方库鸿蒙化适配指南
flutter·华为·harmonyos
夏小鱼的blog3 小时前
【HarmonyOS应用开发入门】第四期:ArkTS语言基础(二)
harmonyos·openharmony
wtrees_松阳3 小时前
【弦断九章·CPU篇】鸿蒙应用性能优化心法
华为·性能优化·harmonyos
2501_946224314 小时前
旅行记录应用统计分析 - Cordova & OpenHarmony 混合开发实战
javascript·harmonyos·harvester
2501_946224315 小时前
旅行记录应用外观设置 - Cordova & OpenHarmony 混合开发实战
javascript·harmonyos·harvester
TAEHENGV5 小时前
回收站模块 Cordova 与 OpenHarmony 混合开发实战
android·java·harmonyos
Nick不懂7 小时前
鸿蒙分布式KVStore冲突解决机制:原理、实现与工程化实践
harmonyos
FrameNotWork8 小时前
深入浅出 HarmonyOS NEXT (迈向 6.0 架构):攻克 ArkTS 高性能状态管理与 NAPI 底层交互难题
架构·交互·harmonyos
个案命题9 小时前
鸿蒙ArkUI状态管理新宠:@Local装饰器全方位解析与实战
microsoft·华为·harmonyos
luxy200410 小时前
【鸿蒙开发实战】HarmonyOS单词库应用
华为·harmonyos