Skip to content

Instantly share code, notes, and snippets.

@omorandi
Last active December 14, 2020 20:51
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save omorandi/59e8b06a6e81d4b8364f to your computer and use it in GitHub Desktop.
Save omorandi/59e8b06a6e81d4b8364f to your computer and use it in GitHub Desktop.
Android: get the actual size of a match_parent/wrap_content view
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
@hornhuang
Copy link

thanks

Copy link

ghost commented Sep 8, 2019

Thanks again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment