Last active
December 14, 2020 20:51
-
-
Save omorandi/59e8b06a6e81d4b8364f to your computer and use it in GitHub Desktop.
Android: get the actual size of a match_parent/wrap_content view
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
view.post(new Runnable() { | |
@Override | |
public void run() { | |
int width = view.getWidth(); | |
int height = view.getHeight(); | |
//do something cool with width and height | |
} | |
}); | |
//the runnable is executed only after the view is completely laid out | |
//less problematic than using ViewTreeObserver.addOnGlobalLayoutListener |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks