美文网首页
android 实现图片手势缩放,移动,双击缩放

android 实现图片手势缩放,移动,双击缩放

作者: 红茶炒饭 | 来源:发表于2019-08-09 09:37 被阅读0次

感谢该控件作者做出的贡献,谢谢

PhotoView

该第三方控件非常好用.
注:该控件根据真机/模拟器的不同 和 使用场景的不同 如:配合ViewPager的使用等情况,在图片初始状态时,进行缩小的时候会报错.

//导入依赖
implementation 'com.github.chrisbanes:PhotoView:2.0.0'
//build.gradle下配置
allprojects {
    repositories {
       
        //添加
        maven {
            url "https://jitpack.io"
        }

    }
}
使用方法

用法几乎与ImgeView没区别. 源码中,该自定义控件继承自ImageView

<com.github.chrisbanes.photoview.PhotoView
            android:src="@drawable/ic_launcher_background"
            android:layout_width="300dp"
            android:layout_height="300dp" />

动态使用

import com.github.chrisbanes.photoview.PhotoView;

PhotoView imageView = new PhotoView(this);
photoview.gif

相关文章

网友评论

      本文标题:android 实现图片手势缩放,移动,双击缩放

      本文链接:https://www.haomeiwen.com/subject/ymfcjctx.html