PhotoView icon indicating copy to clipboard operation
PhotoView copied to clipboard

How to close dialog on click outside the image

Open yaugenka opened this issue 6 years ago • 1 comments

I'm using PhotoView inside a full screen dialog like this

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.github.chrisbanes.photoview.PhotoView
        android:id="@+id/photo_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</RelativeLayout>

The PhotoView width and height are set to match_parent and hence cover the entire screen. If image proportions differ from the screen ones then image is scaled to fit in the center and there will be some unused space in the view. When user clicks on the view, is it possible to detect if the click was done outside the actual image to close the dialog?

Screenshot_1579431662

yaugenka avatar Jan 19 '20 11:01 yaugenka

have a look at setOnOutsidePhotoTapListener method

daniel-micic avatar Nov 13 '23 15:11 daniel-micic