Created
June 13, 2014 03:40
-
-
Save douzifly/833d9b9568f29f0a2953 to your computer and use it in GitHub Desktop.
postOnLayoutFinished
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void postOnLayoutFinished(final View v, final Runnable r) { | |
if (v == null || r == null) { | |
throw new NullPointerException(); | |
} | |
v.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { | |
@Override | |
public void onGlobalLayout() { | |
r.run(); | |
v.getViewTreeObserver().removeGlobalOnLayoutListener(this); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment