美文网首页Android应用开发那些事
手势缩放的ImageView(支持点击、双击事件)

手势缩放的ImageView(支持点击、双击事件)

作者: ZEKI安卓学弟 | 来源:发表于2020-05-20 12:27 被阅读0次

    对于手势放大缩小的ImageView,在网上找了一些,实现的大多差不多。但是缺少功能,于是在别人的基础上自己写了一个。

    ZoomImageView

    项地址:https://github.com/ZYF99/UIKit/tree/1.1/zoomimageview

    • 手势放大缩小
    • 双击放大缩小
    • 放大后手势移动
    • 点击事件
    • 与父控件的滑动冲突解决

    看看效果


    1589948455277.gif 1589948676909.gif

    使用方式

    在app的build.gradle中

    allprojects {
            repositories {
                ...
                maven { url 'https://jitpack.io' }
            }
        }
    
        dependencies {
                implementation 'com.github.ZYF99:UIKit:1.1'
        }
    

    在布局文件中直接使用

        <com.zhangyf.zoomimageview.ZoomImageView
                android:id="@+id/zoom_image"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
    

    如果需要点击事件,这样写(kotlin)

    zoomImageView.onClickAction = {
                //Todo 点击事件
            }
    

    用的还行记得在这点个赞或者去github给个星星~

    相关文章

      网友评论

        本文标题:手势缩放的ImageView(支持点击、双击事件)

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