티스토리 뷰

별도의 구현 없이 간단히 Pinch to Zoom기능을 구현


[라이브러리 추가]

1
2
3
dependencies {
  compile 'com.commit451:PhotoView:1.2.4'
}
cs

[이미지 뷰에 추가]
mAttacher = new PhotoViewAttacher(mImageView);
아래 소스 확인
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
ImageView mImageView;
PhotoViewAttacher mAttacher;
 
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
 
    // Any implementation of ImageView can be used!
    mImageView = (ImageView) findViewById(R.id.iv_photo);
 
    // Set the Drawable displayed
    Drawable bitmap = getResources().getDrawable(R.drawable.wallpaper);
    mImageView.setImageDrawable(bitmap);
 
    // Attach a PhotoViewAttacher, which takes care of all of the zooming functionality.
    mAttacher = new PhotoViewAttacher(mImageView);
}
 
 
// If you later call mImageView.setImageDrawable/setImageBitmap/setImageResource/etc then you just need to call
mAttacher.update();
cs


[GITHUB 링크]

https://github.com/chrisbanes/PhotoView

'Android Library' 카테고리의 다른 글

CircularProgressBar  (0) 2016.05.16
이미지로드 라이브러리 android-query  (0) 2016.04.11
CircleImageView  (0) 2015.07.27
댓글