Created
December 10, 2014 18:20
-
-
Save Jawnnypoo/1b6b2d035628f387a2c5 to your computer and use it in GitHub Desktop.
Example of setting an onPreDrawListener on a view
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
final View view = findViewById(R.id.view_id); | |
view.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { | |
@Override | |
public boolean onPreDraw() { | |
view.getViewTreeObserver().removeOnPreDrawListener(this); | |
//Do the things you want to do. Return true if you want to draw that frame, otherwise return false | |
return false; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It will be used to draw the children of a view group related to its parent width and height.