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.
Asked
Active
Viewed 4,186 times
11

DariusL
- 4,007
- 5
- 32
- 44
1 Answers
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:

theshadowchild
- 401
- 4
- 6
-
The implementation is nearly identical to mine pre-kitkat. `view.getWidth() > 0 && view.getHeight() > 0`. I guess this is the closest I'll get to a solution without using a listener to set a flag. – DariusL Aug 11 '15 at 11:34
-
The link is broken. – Eli Jul 10 '17 at 06:50
-
1Fixed the busted link, @Elisa. – theshadowchild Jul 11 '17 at 14:34