I am using PhotoView to implement Pinch to Zoom feature. Fortunately enough, my app is able to fetch the picture from the given uri
, but when it comes to display it, it only shows a transparent box.
image_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<com.github.chrisbanes.photoview.PhotoView
android:id="@+id/zoom_iv"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Kotlin code to achieve the functionality:
...
binding.image.setOnClickListener(){
ImageLayoutDialog()
}
...
...
...
private fun ImageLayoutDialog() {
val imageLayoutBinding =
ImageLayoutBinding.inflate(LayoutInflater.from(requireContext()))
val photoView: PhotoView = imageDialogBinding.zoomIv
val mBuilder = AlertDialog.Builder(requireContext())
.setView(
imageLayoutBinding .root
)
Glide.with(requireActivity())
.load(customUri)
.into(photoView)
val mAlertDialog : AlertDialog = mBuilder.create()
mAlertDialog.show()
mAlertDialog.setCanceledOnTouchOutside(false)
}
When I click on image
I get a transparent screen. But I am expecting the contents of customUri
there. Any solution to this?
EDIT 1.0
Now the dialog box loads up. But it doesn't shows the image, after setting the view.