10

Is there a backwards compatible way to find out if a view is laid out? View has isLaidOut, but it's API 19. I currently use if(view.getWidth() + view.getHeight() > 0), but it doesn't look like a stable and clean way to do this. I'm aware of OnGlobalLayoutListener, but I want to know if a view is laid out right now.

DariusL
  • 3,927
  • 5
  • 31
  • 43

1 Answers1

15

This also had me stumped for a while.

If you're using the support-v4 libraries, then you can use:

ViewCompat.isLaidOut(View)

Check out the implementation:

ViewCompat.java

ViewCompatBase.java

theshadowchild
  • 381
  • 3
  • 6