图片放大、平移框架PhotoView

添加依赖

compile 'com.github.chrisbanes.photoview:library:1.2.4'

xml中

<uk.co.senab.photoview.PhotoView
    android:id="@+id/iv"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

.class中

PhotoView photoView = (PhotoView) findViewById(R.id.iv);
photoView.setImageResource(R.mipmap.image1);

支持Picasso、Glide、等加载其他图片框架;因为PhotoView他是ImageView的子类。

  final PhotoView photoView = (PhotoView) findViewById(R.id.iv_photo);

        Picasso.with(this)
                .load("http://pbs.twimg.com/media/Bist9mvIYAAeAyQ.jpg")
                .into(photoView);

        Glide.with(this)
                .load("http://pbs.twimg.com/media/Bist9mvIYAAeAyQ.jpg")
                .into(photoView);

 

ViewPager中使用 ,-1,-1代表匹配父容器 

// Now just add PhotoView to ViewPager and return it   

//public static final int MATCH_PARENT = -1;

//public static final int WRAP_CONTENT = -2;

@Override
        public View instantiateItem(ViewGroup container, int position) {
            PhotoView photoView = new PhotoView(container.getContext());
            photoView.setImageResource(sDrawables[position]); 

            container.addView(photoView,-1,  -1);

            return photoView;
        }

源github地址

https://github.com/chrisbanes/PhotoView

 

 

 

 

 

 

 

 

 

 

转载于:https://my.oschina.net/u/3015461/blog/918179

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值