Android 多點觸控與圖片縮放

ScaleImageview

一個圖片縮放控件,支持在viewpager等滑動控件中使用android

文章講解以下:Android 多點觸控與圖片縮放git

演示效果

scale.gif

使用

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
複製代碼

而後在你的 module 中添加:github

implementation 'com.github.LillteZheng:ScaleImageview:1.0'
複製代碼

而後添加控件便可:bash

<com.zhengsr.mylibrary.ScaleImageView
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:layout_margin="10dp"
    app:scale_limit_board="false"
    app:scale_max_factor="5"
    app:scale_auto_time="5"
    app:scale_double_factor="2"
    android:src="@mipmap/a1"/>

複製代碼

自定義屬性

縮放控件 ScaleImageViewapp

名稱 類型 說明
scale_auto_time reference,integer 雙擊時,達到放大的時間
scale_limit_board boolean 是否限制邊界,即不能縮放到比控件小
scale_autofit boolean 自動適配縮放值,有些圖片是正方形,若是你的高度沒設定好,建議設置爲false,不能會變形
scale_double_factor integer 雙擊時放大倍數
scale_max_factor integer 可放大的最大倍數
scale_interrupt_parent_touch boolean 是否截獲父控件觸摸事件,放大時,須要截取,否則沒法移動
相關文章
相關標籤/搜索