Android触摸放大ImageView中的图片

Android UI Libs之PhotoView

1. 说明

PhotoView可以协助我们快速简单的实现一个放大ImageView中图片的功能,这个功能在查看图片时超级常用,通过触摸放大图片。

2. 配置

  • 第一在工程的build.gradle上面添加JitPack仓库

    allprojects {

    repositories { …

    maven { url “https://jitpack.io” }

    }

    }

  • 其次,在模块的build.gradle上面添加依赖

    dependencies {

    compile ‘com.github.chrisbanes:PhotoView:1.2.6’}

3. 基本使用

使用该库来放大ImageView中图片有两种方式:

  • 直接使用PhoteView

    在xml中定义PhoteView

    <uk.co.senab.photoview.PhotoView

    android:id=”@+id/image”

    android:src=”@drawable/image”

    android:scaleType=”fitXY”

    android:layout_width=”match_parent”

    android:layout_height=”match_parent” />

    程序运行界面如下:

    Android触摸放大ImageView中的图片

  • 配合PhotoViewAttacher使用ImageView

    在xml中定义ImageView

    <ImageView

    android:id=”@+id/image”

    android:src=”@drawable/image”

    android:scaleType=”fitXY”

    android:layout_width=”match_parent”

    android:layout_height=”match_parent” />

    在java文件中进行相关操作:

    this.image = (ImageView) findViewById(R.id.image);

    mAttacher = new PhotoViewAttacher(image);

    程序运行界面如下:

    Android触摸放大ImageView中的图片

Android UI Libs之PhotoView

1. 说明

PhotoView可以协助我们快速简单的实现一个放大ImageView中图片的功能,这个功能在查看图片时超级常用,通过触摸放大图片。

2. 配置

  • 第一在工程的build.gradle上面添加JitPack仓库

    allprojects {

    repositories { …

    maven { url “https://jitpack.io” }

    }

    }

  • 其次,在模块的build.gradle上面添加依赖

    dependencies {

    compile ‘com.github.chrisbanes:PhotoView:1.2.6’}

3. 基本使用

使用该库来放大ImageView中图片有两种方式:

  • 直接使用PhoteView

    在xml中定义PhoteView

    <uk.co.senab.photoview.PhotoView

    android:id=”@+id/image”

    android:src=”@drawable/image”

    android:scaleType=”fitXY”

    android:layout_width=”match_parent”

    android:layout_height=”match_parent” />

    程序运行界面如下:

    Android触摸放大ImageView中的图片

  • 配合PhotoViewAttacher使用ImageView

    在xml中定义ImageView

    <ImageView

    android:id=”@+id/image”

    android:src=”@drawable/image”

    android:scaleType=”fitXY”

    android:layout_width=”match_parent”

    android:layout_height=”match_parent” />

    在java文件中进行相关操作:

    this.image = (ImageView) findViewById(R.id.image);

    mAttacher = new PhotoViewAttacher(image);

    程序运行界面如下:

    Android触摸放大ImageView中的图片

Android UI Libs之PhotoView

1. 说明

PhotoView可以协助我们快速简单的实现一个放大ImageView中图片的功能,这个功能在查看图片时超级常用,通过触摸放大图片。

2. 配置

  • 第一在工程的build.gradle上面添加JitPack仓库

    allprojects {

    repositories { …

    maven { url “https://jitpack.io” }

    }

    }

  • 其次,在模块的build.gradle上面添加依赖

    dependencies {

    compile ‘com.github.chrisbanes:PhotoView:1.2.6’}

3. 基本使用

使用该库来放大ImageView中图片有两种方式:

  • 直接使用PhoteView

    在xml中定义PhoteView

    <uk.co.senab.photoview.PhotoView

    android:id=”@+id/image”

    android:src=”@drawable/image”

    android:scaleType=”fitXY”

    android:layout_width=”match_parent”

    android:layout_height=”match_parent” />

    程序运行界面如下:

    Android触摸放大ImageView中的图片

  • 配合PhotoViewAttacher使用ImageView

    在xml中定义ImageView

    <ImageView

    android:id=”@+id/image”

    android:src=”@drawable/image”

    android:scaleType=”fitXY”

    android:layout_width=”match_parent”

    android:layout_height=”match_parent” />

    在java文件中进行相关操作:

    this.image = (ImageView) findViewById(R.id.image);

    mAttacher = new PhotoViewAttacher(image);

    程序运行界面如下:

    Android触摸放大ImageView中的图片

Android UI Libs之PhotoView

1. 说明

PhotoView可以协助我们快速简单的实现一个放大ImageView中图片的功能,这个功能在查看图片时超级常用,通过触摸放大图片。

2. 配置

  • 第一在工程的build.gradle上面添加JitPack仓库

    allprojects {

    repositories { …

    maven { url “https://jitpack.io” }

    }

    }

  • 其次,在模块的build.gradle上面添加依赖

    dependencies {

    compile ‘com.github.chrisbanes:PhotoView:1.2.6’}

3. 基本使用

使用该库来放大ImageView中图片有两种方式:

  • 直接使用PhoteView

    在xml中定义PhoteView

    <uk.co.senab.photoview.PhotoView

    android:id=”@+id/image”

    android:src=”@drawable/image”

    android:scaleType=”fitXY”

    android:layout_width=”match_parent”

    android:layout_height=”match_parent” />

    程序运行界面如下:

    Android触摸放大ImageView中的图片

  • 配合PhotoViewAttacher使用ImageView

    在xml中定义ImageView

    <ImageView

    android:id=”@+id/image”

    android:src=”@drawable/image”

    android:scaleType=”fitXY”

    android:layout_width=”match_parent”

    android:layout_height=”match_parent” />

    在java文件中进行相关操作:

    this.image = (ImageView) findViewById(R.id.image);

    mAttacher = new PhotoViewAttacher(image);

    程序运行界面如下:

    Android触摸放大ImageView中的图片

Android UI Libs之PhotoView

1. 说明

PhotoView可以协助我们快速简单的实现一个放大ImageView中图片的功能,这个功能在查看图片时超级常用,通过触摸放大图片。

2. 配置

  • 第一在工程的build.gradle上面添加JitPack仓库

    allprojects {

    repositories { …

    maven { url “https://jitpack.io” }

    }

    }

  • 其次,在模块的build.gradle上面添加依赖

    dependencies {

    compile ‘com.github.chrisbanes:PhotoView:1.2.6’}

3. 基本使用

使用该库来放大ImageView中图片有两种方式:

  • 直接使用PhoteView

    在xml中定义PhoteView

    <uk.co.senab.photoview.PhotoView

    android:id=”@+id/image”

    android:src=”@drawable/image”

    android:scaleType=”fitXY”

    android:layout_width=”match_parent”

    android:layout_height=”match_parent” />

    程序运行界面如下:

    Android触摸放大ImageView中的图片

  • 配合PhotoViewAttacher使用ImageView

    在xml中定义ImageView

    <ImageView

    android:id=”@+id/image”

    android:src=”@drawable/image”

    android:scaleType=”fitXY”

    android:layout_width=”match_parent”

    android:layout_height=”match_parent” />

    在java文件中进行相关操作:

    this.image = (ImageView) findViewById(R.id.image);

    mAttacher = new PhotoViewAttacher(image);

    程序运行界面如下:

    Android触摸放大ImageView中的图片

程序源代码下载,我的github仓库:
https://github.com/lavor-zl/UILibs

欢迎关注我的简书专题:Android技术漫谈

欢迎关注我的微信公众号:Android技术漫谈

© 版权声明
THE END
如果内容对您有所帮助,就支持一下吧!
点赞0 分享
评论 共1条

请登录后发表评论