Skip to content

Instantly share code, notes, and snippets.

@scompt
Created May 31, 2012 07:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scompt/2841608 to your computer and use it in GitHub Desktop.
Save scompt/2841608 to your computer and use it in GitHub Desktop.
public final void onMeasure(final int widthMeasureSpec,
final int heightMeasureSpec) {
int mode = View.MeasureSpec.getMode(widthMeasureSpec);
int width = View.MeasureSpec.getSize(widthMeasureSpec);
int height = (int) (width / aspect.ratio);
int heightSpec = MeasureSpec.makeMeasureSpec(height, mode);
super.onMeasure(widthMeasureSpec, heightSpec);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment