Photoview: the imgview is not int the center, when i use the PhotoViewAttacher

Created on 31 Jan 2016  路  15Comments  路  Source: Baseflow/PhotoView

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 .

Most helpful comment

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. https://github.com/SimpleMobileTools/Simple-Gallery/commit/3983428d5fd4810e28fadd915a59ca08558ba4ae

All 15 comments

Yes. I have same issue 馃槦

Image in Top Left Position:
img_6436

Image in Center:
img_6437

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

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

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

Setting zoomable to false resolved my issue.

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.

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. https://github.com/SimpleMobileTools/Simple-Gallery/commit/3983428d5fd4810e28fadd915a59ca08558ba4ae

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

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.

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

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

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);
}
});

you guyz are awesome thanks

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

Thank you

Was this page helpful?
0 / 5 - 0 ratings