StfalconImageViewer
StfalconImageViewer copied to clipboard
click to dismiss
I want to make him disappear when I click, how can I do it?
Please, add this functionality
I used an overlay view to add a close button, which I could then add an OnClickListener to, to close the image viewer:
private StfalconImageViewer<String> imageViewer;
public MyClass(Activity context)
{
this.pictureDetailsView = context.getLayoutInflater().inflate(R.layout.item_image_overlay_view, null, false);
this.imageViewer = new StfalconImageViewer.Builder<>(context, imageUrlList, imageLoader)
.withStartPosition(0)
.withOverlayView(pictureDetailsView)
.build();
ImageView closeImageView = this.pictureDetailsView.findViewById(R.id.ivCloseImageView);
closeImageView.setOnClickListener(v ->
{
if(imageViewer != null)
{
imageViewer.close();
}
});
}
item_image_overlay_view.xml <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent">
<ImageView
android:id="@+id/ivCloseImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:clickable="true"
android:focusable="true"
app:srcCompat="@drawable/ic_close"
app:tint="@color/mea_background_90" />
I think a good way to do this is through . withOverlayView;
custom overlay to recognize click event