0

Possible Duplicate:
How can I check if a view is visible or not in Android?

We can setVisibility to VISIBLE, GONE and INVISIBLE.
However, can we check the Visibility in such activity so that we can know which view is gone or which view is visible??

Community
  • 1
  • 1
jjLin
  • 3,281
  • 8
  • 32
  • 55

2 Answers2

3
you're looking for:

if (myImageView.getVisibility() == View.VISIBLE) 
{
    // Its visible
} 
else 
{
    // Either gone or invisible
}
Chirag
  • 56,621
  • 29
  • 151
  • 198
1

You can check that using yourView.getVisibility(); you could also use isShown();

One difference is that isShown(); returns true if this view and all of its ancestors are VISIBLE and getVisibility(); returns One of VISIBLE, INVISIBLE, or GONE.

Hope that helps.

Android Reference.

0gravity
  • 2,682
  • 4
  • 24
  • 33