Skip to content

Instantly share code, notes, and snippets.

@markushi
Last active December 19, 2015 13:58
Show Gist options
  • Save markushi/5965445 to your computer and use it in GitHub Desktop.
Save markushi/5965445 to your computer and use it in GitHub Desktop.
Elegant solution to determine view width and height after the view has been measured.
@Override
public void onCreate(Bundle savedInstanceState) {
final View view = findViewById(...)
view.post(new Runnable() {
@Override
public void run() {
int width = view.getWidth();
int height = view.getHeight();
...
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment