Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find if a view is laid out

Tags:

android

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.

like image 419
DariusL Avatar asked Dec 17 '14 09:12

DariusL


1 Answers

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

like image 105
theshadowchild Avatar answered Oct 23 '22 23:10

theshadowchild