PhotoView简单实用

/**

  • 功能描述 :
  • 创建时间 : 2017/6/26 19:38
  • 编写人 : 王成哲
    */

public class HackyViewPager extends ViewPager {
public HackyViewPager(Context context) {
super(context);
}
public HackyViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
try {
return super.onInterceptTouchEvent(ev);
} catch (IllegalArgumentException e) {
return false;
}
}
}

适配器
mPager.setAdapter(new PagerAdapter() {

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        PhotoView mPhotoView=new PhotoView(MainActivity.this);
        Glide.with(container.getContext())
                .load(images.get(position))
                .into(mPhotoView);
        container.addView(mPhotoView);

        return mPhotoView;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);
    }

    @Override
    public int getCount() {
        return images.size();
    }
    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view==object;
    }
});

}

你可能感兴趣的:(PhotoView简单实用)