Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the imgview is not int the center, when i use the PhotoViewAttacher #320

Closed
AnswerZhao opened this issue Jan 31, 2016 · 14 comments
Closed

Comments

@AnswerZhao
Copy link

the imgview is not int the center, when i use the PhotoViewAttacher. The photo is always at the top ,but when i touch the photo , the photo move to the center.Please help me .

@devapalanisamy
Copy link

Yes. I have same issue 😟

@devapalanisamy
Copy link

Image in Top Left Position:
img_6436

Image in Center:
img_6437

@Jawnnypoo
Copy link
Contributor

Pasting some XML in here to show how the layout looks would be helpful

@devapalanisamy
Copy link

@Jawnnypoo I am creating ImageView Programmatically and adding it to layout.

@Jawnnypoo
Copy link
Contributor

Can you paste the code you are using to programatically add the view then?

@devapalanisamy
Copy link

Setting zoomable to false resolved my issue.

@AnswerZhao
Copy link
Author

I have resolve it. in the viewpager, when you show image using the PhotoViewAttacher, the image always don't show in the center, i don't know why. However,i found the right way is to use the PhotoView in the adapter of viewpager.

@tibbi
Copy link

tibbi commented Feb 21, 2016

It was broken the same way for me too, while adding the PhotoViewAttacher in InstantiateItem at my PagerAdapter. However using the PhotoView instead of ImageView as written at the sample fixed it. It was broken the same way on android 4.3 and 5.1.1. If the image was too high, it was alligned Left instead of Top. Here is a commit from going the broken to the working version in case you need it. SimpleMobileTools/Simple-Gallery@3983428

@ghost
Copy link

ghost commented Mar 6, 2016

@tibbi have been experiencing this too, solved with help of you. Thanks for sharing the code!

@E2Clince
Copy link

E2Clince commented Apr 1, 2016

When I set zoomable to false image view is showed OK. Also when I use PhotoView. But those solutions are not valid for me because I NEED zoom and a center image.

@yurimmm
Copy link

yurimmm commented Apr 6, 2016

@E2Clince I finally found a solution!! Refer to this website!
http://stackoverflow.com/questions/33479400/android-photoview-setdisplaymatrix

@lixplor
Copy link

lixplor commented Apr 13, 2016

@tibbi 's way works for me. Use PhotoView instead of ImageView. Thanks!!

@yeonkyuJeong
Copy link

I solved this issue. using the next way.
mAttacher.setOnScaleChangeListener(new PhotoViewAttacher.OnScaleChangeListener() {
@OverRide
public void onScaleChange(float scaleFactor, float focusX, float focusY) {
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
params.addRule(RelativeLayout.CENTER_IN_PARENT);
mAttacher.getImageView().setLayoutParams(params);
}
});

@fuzyfuzi17
Copy link

you guyz are awesome thanks

@developerawt
Copy link

@AnswerZhao i am facing same issue could you please tell me how to resolve it..

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants