控件:photoView單點/多點觸摸來進行圖片縮放

GitHub - chrisbanes/PhotoView: Implementation of ImageView for Android that supports zooming, by various touch gestures. https://github.com/chrisbanes/PhotoView

添加依賴

 repositories {
        maven { url "https://jitpack.io" }
    }

我的是compile 'com.android.support:appcompat-v7:26.+'但PhotoView自身包含的appcompat-v7與我的版本不一致。

compile ('com.github.chrisbanes:PhotoView:2.1.4'){
        exclude group: 'com.android.support', module: 'appcompat-v7'
    }

xml佈局

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <com.github.chrisbanes.photoview.PhotoView
        android:id="@+id/photo_view"
        android:scaleType="centerCrop"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="10dp"
        android:src="@drawable/beauty1"/>
</android.support.constraint.ConstraintLayout>

activity

 PhotoViewAttacher mAttacher = new PhotoViewAttacher(photoView);
        mAttacher.setMaximumScale((float)6.0);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章