matabii / scale-imageview-android Goto Github PK
View Code? Open in Web Editor NEWAdd pinch-in and pinch-out function to Android ImageVIew.
License: MIT License
Add pinch-in and pinch-out function to Android ImageVIew.
License: MIT License
Hello! I have been testing your code and I'm not able to found why my image don't fit all the screen.
On both orientations i have on sides i.e: horizontal, i have white space west and east sides.. i want the images takes all the available spaces.
Hope you can help me! Great work!
First of all, thanks for the nice widget! There is a problem though when using the ScaleImageView with a ViewPager, weird things happen because the pager feeds unexpected values to the setFrame method. The problems is fixed in the code below.
protected boolean setFrame(int l, int t, int r, int b) {
mWidth = r - l;
mHeight = b - t;
mMatrix.reset();
/* When using this with a ViewPager, r can be for example -960 while l is -1440.
* This is totally uncool, so we should make sure that the values are within
* the screen size limits when used for other calculations.
*/
int r_norm = r - l;
mScale = (float) r_norm / (float) mIntrinsicWidth;
int paddingHeight = 0;
int paddingWidth = 0;
// scaling vertical
if (mScale * mIntrinsicHeight > mHeight) {
mScale = (float) mHeight / (float) mIntrinsicHeight;
mMatrix.postScale(mScale, mScale);
paddingWidth = (r_norm - mWidth) / 2;
paddingHeight = 0;
// scaling horizontal
} else {
mMatrix.postScale(mScale, mScale);
paddingHeight = (b - mHeight) / 2;
paddingWidth = 0;
}
mMatrix.postTranslate(paddingWidth, paddingHeight);
setImageMatrix(mMatrix);
mMinScale = mScale;
zoomTo(mScale, mWidth / 2, mHeight / 2);
cutting();
return super.setFrame(l, t, r, b);
}
I wanted it to be of zoom scale 1 on load (so it looks exactly like ImageView) but on some images (depending on width to height ratio) it is zoomed slightly so can't see the whole image until manually zoom out by pinching the image.
I'm still debugging on where the calculation went wrong but haven't got an answer yet. If someone have please let me know thanks!
Without a license, your project risks not being usable by others. Please help out those of us who don't want to give lawyers more business than they need by selecting an appropriate license. The MIT license, the Apache License, the BSD License, the Microsoft Public License -- they all seem like good candidates.
Hi, I am glad to have found out this project here. This is not an issue, it's more like I want to know the way to enable or disable ScaleImageview programmatically. Is it possible?
Hi,
I have checked your app it's working properly when image load from drawable or assign directly, but it's not working when I have used Picasso for a loading image.
ScaleImageView imgPhotoView = (ScaleImageView) findViewById(R.id.activity_photo_view_img);
Picasso.with(this).load(photoURL).fit().centerInside().into(imgPhotoView);
How can I check if my ImageView is zoomed or if it is shown as it is as default?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.