Hi i am new to Android application i want to Zoom-in and Zoom-out ImageView.I tried most of the sample but in all that image in the imageview is get Zoom-in and Zoom-out.I want to Zoom-in and Zoom-out ImageView.I want to increase imageview width and height while Zoom-in and reduce imageview width and height while Zoom-out.Can any one suggest me?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
Simple way:
Add below line in
build.gradle
:Just change ACTION_MOVE_EVENT in Chirag Raval Answer to set ZOOM_IN LIMIT
I got the most helpful answer from @Nicolas Tyler but I had issues with how the syntax and logic worked. I also did not want any Alpha space and my Algebra was rusty! After 3 days I have put together my own version of this.
My answer differs from @Nicolas Tyler with the following:
Different variable names which I found made more sense in underlying contextual uses
This Pinch-Zoom image class does NOT show alpha space and will let you zoom in and out and still not let you over/under pan an image and reveal alpha space
Added deep comments to the matrix section to explain what was going on with the math involved
This image class will also let you pass in a resourceId and it will create a bitmap from it
Much simpler algorithms for both scaling and translation and few variables
Changing the image within this will cause it to zoom in/out such that the new image takes up the view container
A great resource refresher on Algebra can be found here: https://youtu.be/IiXB6tYtY4w?t=4m12s That video covers the core of Scalar and Translation matrixes (and will help you make sense of the MTRANS_X and MTRANS_Y stuff). If you have questions ask and I will do my best to answer (but I am NO Algebra expert).
If you want to set scale of an image before showing, use this class: https://github.com/MikeOrtiz/TouchImageView/blob/master/src/com/ortiz/touch/TouchImageView.java.
Also the image can be resized with double tap.
If you use the
ImageView
inside aViewPager
, apply this fix: https://github.com/MikeOrtiz/TouchImageView/issues/125.just use this class : TouchImageView
I know it is a bit late for this answer, but I hope it helps someone.
I was looking for the same thing (Zoom using pinch, and dragging image) and I found this Android Developers Blog link.
Works perfect. No artifacts or what so ever. It uses
ScaleGestureDetector
.