PhotoView的简介:
PhotoView是一款扩展自AndroidImageView,支持通过单点/多点触摸来进行图片缩放的智能控件。功能实用和强大。
PhotoView的功能:
双指缩放
单点触摸缩放
基本用法:
导入jar包,布局XML里设置PhotoView
将ImageView传入PhotoViewAttacher
代码演示:
布局文件中:
spanstyle="background-color:rgb(255,255,255);"LinearLayoutxmlns:android=""
xmlns:tools=""
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical"
android:id="@+id/iv_photo1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/
android:id="@+id/iv_photo2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/
/LinearLayout/span
MainActivity中:
privatePhotoViewiv_photo1;
privatePhotoViewiv_photo2;
@Override
protectedvoidonCreate(BundlesavedInstanceState){
(savedInstanceState);
setContentView(_main);
iv_photo1=(PhotoView)findViewById(_photo1);
iv_photo2=(PhotoView)findViewById(_photo2);
//localImage();
netImage();
}
/**
*加载本地图片
*
*/
privatevoidlocalImage(){
//加载本地图片,缩放处理
try{
//图片在asset目录中
InputStreamis=getAssets().open("");
Bitmapbm=(is);
iv_(bm);
}catch(IOExceptione){
();
}
}
/**
*加载网络图片
*/
privatevoidnetImage(){
ImageLoaderloader=();
("",iv_photo2);
iv_(newOnPhotoTapListener(){
@Override
publicvoidonPhotoTap(Viewarg0,floatarg1,floatarg2){
}
});
}
}
需要导入的jar包:
[免责声明]本文来源于网络,不代表本站立场,如转载内容涉及版权等问题,请联系我们会予以删除相关文章,保证您的权利。转载请注明出处






