11

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
  • 4,007
  • 5
  • 32
  • 44

1 Answers1

17

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
  • 401
  • 4
  • 6