Search code examples
androidviewphotoviewer

How to move View of PhotoView


I'm using uk.co.senab.photoview.PhotoView.
When zoom-in, the image of photoview will larger than mobile screen.
So, I want to make button that move mobile screen to center of the image, and the image still zoomed. I have no idea which variable I have to set in OnClickListener.
I try these but nothing happen.

moveToCenterButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        mAttacher.getDisplayRect().left = 100;
        mAttacher.getDisplayRect().top = 300;
    }
});

Solution

  • setScale has x, y argument that is the (x,y) position of your top-left corner of your view.

    mAttacher.setScale(scale, x, y, animate);