Created
May 3, 2017 07:31
-
-
Save truongngoclinh/f180c582a79b5e4bdd62ede4f3748d9f to your computer and use it in GitHub Desktop.
Catch view changes
This file contains hidden or 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 LinearLayout layout = (LinearLayout) findViewById(R.id.YOUR_VIEW_ID); | |
ViewTreeObserver vto = layout.getViewTreeObserver(); | |
vto.addOnGlobalLayoutListener (new OnGlobalLayoutListener() { | |
@Override | |
public void onGlobalLayout() { | |
layout.getViewTreeObserver().removeOnGlobalLayoutListener(this); | |
int width = layout.getMeasuredWidth(); | |
int height = layout.getMeasuredHeight(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment