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
I’m a physicist specializing in computational material science with a PhD in Physics from Friedrich-Schiller University Jena, Germany. I write efficient codes for simulating light-matter interactions at atomic scales. I like to develop Physics, DFT, and Machine Learning related apps and software from time to time. Can code in most of the popular languages. I like to share my knowledge in Physics and applications using this Blog and a YouTube channel.