View.getVisibility()
gets the visibility of a View, but its not a simple true/false. A view can have its visibility set to one of three things.
View.VISIBLE
The view is visible.
View.INVISIBLE
The view is invisible, but any spacing it would normally take up will still be used. Its “invisible”
View.GONE
The view is gone, you can’t see it and it doesn’t take up the “spot”.
So to check whether the View is visible or not and then do something accordingly, you could use the following code:
if (myImageView.getVisibility() == View.VISIBLE) { // Its visible } else { // Either gone or invisible }
References:
StackOverflow
[wpedon id="7041" align="center"]