PhotoView的用法
来源:互联网 发布:联想e41指纹识别软件 编辑:程序博客网 时间:2024/05/20 19:45
今天开发中,要对图片进行处理,然后我用到了PhotoView ,这里就记录下用法。
项目地址:https://github.com/chrisbanes/PhotoView
原理剖析文档:http://a.codekk.com/detail/Android/dkmeteor/PhotoView%20%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90
Demo地址:https://raw.githubusercontent.com/android-cn/android-open-project-demo/master/photoview-demo/app/photoview-demo.apk
Demo中PhotoView的用法。用法比较简单,直接代码解释。
1.FullScreenDemo
3.ImageLoaderDemo
项目地址:https://github.com/chrisbanes/PhotoView
原理剖析文档:http://a.codekk.com/detail/Android/dkmeteor/PhotoView%20%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90
Demo地址:https://raw.githubusercontent.com/android-cn/android-open-project-demo/master/photoview-demo/app/photoview-demo.apk
Demo中PhotoView的用法。用法比较简单,直接代码解释。
1.FullScreenDemo
java代码
import uk.co.senab.photoview.PhotoView;import android.app.Activity;import android.os.Bundle;public class FullScreenDemo extends Activity {private PhotoView mPhotoView;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_fullscreen);mPhotoView = (PhotoView) findViewById(R.id.photoview);mPhotoView.setImageResource(R.drawable.saya);}}
xml文件
2.ViewPagerDemo<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <uk.co.senab.photoview.PhotoView android:id="@+id/photoview" android:layout_width="match_parent" android:layout_height="match_parent" /></LinearLayout>
java代码
import uk.co.senab.photoview.PhotoView;import android.app.Activity;import android.os.Bundle;import android.support.v4.view.PagerAdapter;import android.support.v4.view.ViewPager;import android.view.View;import android.view.ViewGroup;import android.view.ViewGroup.LayoutParams;public class ViewPagerDemo extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_viewpager);ViewPager pager = (ViewPager) findViewById(R.id.viewpager);pager.setAdapter(new DemoAdapter());}class DemoAdapter extends PagerAdapter {@Overridepublic int getCount() {return 3;}@Overridepublic void destroyItem(ViewGroup container, int position, Object object) {container.removeView((View) object);}@Overridepublic boolean isViewFromObject(View view, Object object) {return view == object;}@Overridepublic Object instantiateItem(ViewGroup container, int position) {PhotoView photoview = new PhotoView(ViewPagerDemo.this);photoview.setImageResource(R.drawable.saya);container.addView(photoview, LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT);return photoview;}}}
xml文件
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <android.support.v4.view.ViewPager android:id="@+id/viewpager" android:layout_width="match_parent" android:layout_height="match_parent" /></LinearLayout>
3.ImageLoaderDemo
java代码
4.PicassoDemoimport com.nostra13.universalimageloader.core.ImageLoader;import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;import uk.co.senab.photoview.PhotoView;import android.app.Activity;import android.os.Bundle;public class ImageLoaderDemo extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_integration);PhotoView photoView = (PhotoView) findViewById(R.id.photoview);ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(this));/** * The Image URL is comes from my space. If it is invalid, you can * change to any other picture url. */ImageLoader.getInstance().displayImage("http://img5.imgtn.bdimg.com/it/u=854933491,3774339278&fm=21&gp=0.jpg", photoView);}}xml文件
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <uk.co.senab.photoview.PhotoView android:id="@+id/photoview" android:layout_width="match_parent" android:layout_height="match_parent" /></LinearLayout>
java代码
import uk.co.senab.photoview.PhotoView;import android.app.Activity;import android.os.Bundle;import android.util.DisplayMetrics;import com.squareup.picasso.Picasso;public class PicassoDemo extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_integration);PhotoView photoView = (PhotoView) findViewById(R.id.photoview);DisplayMetrics dm = new DisplayMetrics();getWindowManager().getDefaultDisplay().getMetrics(dm);Picasso.with(this).load("http://img5.imgtn.bdimg.com/it/u=854933491,3774339278&fm=21&gp=0.jpg").centerInside().resize(dm.widthPixels, dm.heightPixels).tag(this).into(photoView);}}
xml文件
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <uk.co.senab.photoview.PhotoView android:id="@+id/photoview" android:layout_width="match_parent" android:layout_height="match_parent" /></LinearLayout>
2 0
- PhotoView的用法
- android PhotoView的用法
- Photoview依赖及用法
- PhotoView图片的放大和缩小的用法
- 关于Android 开源控件 photoview 的单击用法
- PhotoView之基础用法详解
- PhotoView的使用方法
- PhotoView的简单使用方法
- PhotoView的异常问题
- 开源库PhotoView的使用
- PhotoView的使用方法
- PhotoView的基本使用
- PhotoView的一些坑
- photoview的使用
- 使用PhotoView的问题解决
- PhotoView的基本使用
- PhotoView的简单使用方法
- PhotoView的使用
- 环信即时通讯-服务器端集成(REST API)-php版demo
- 手把手带你画一个动态错误提示 Android自定义view
- js正则
- TCL QUHD引行业遐想,中国有望成为显示行业绝对霸主
- GCD的顺序下载
- PhotoView的用法
- Vika and Squares
- 程序员应该关注的一些事
- ceph源码分析:Admin Socket机制
- 转载自简书iOS 异步绘制相关
- Facade模式——设计模式学习笔记
- 基于opencv的人脸性别识别
- 【leetcode】:Range Sum Query - Immutable
- View的基础知识和Scroller的使用