My goal is to zoom in an image with a long press and then zoom out. The concern is that this image, once unzoomed, remains in the foreground due to the use of the bringToFront () instruction. We should be able to use the reverse of bringToFront () which does not exist, so how to do it?
Below is the code I wrote. Thank you for any idea which will be welcome.
fun Activity.zoomInOut(iv: ImageView, tv: TextView, isZoomedIn: Boolean): Boolean {
val isZoomed: Boolean
if (isZoomedIn) {
val animZoomOut = AnimationUtils.loadAnimation(
applicationContext, R.anim.zoom_out
)
iv.startAnimation(animZoomOut)
tv.startAnimation(animZoomOut)
isZoomed = false
} else {
val animZoomIn = AnimationUtils.loadAnimation(
applicationContext, R.anim.zoom_in
)
iv.startAnimation(animZoomIn)
tv.startAnimation(animZoomIn)
isZoomed = true
iv.bringToFront()
tv.bringToFront()
}
return isZoomed
}