Skip to content

Instantly share code, notes, and snippets.

@defHLT
Created April 2, 2015 01:26
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 defHLT/fb39189c0bad5d07cdbd to your computer and use it in GitHub Desktop.
Save defHLT/fb39189c0bad5d07cdbd to your computer and use it in GitHub Desktop.
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
float scale = getMeasuredWidth() / mMaxImageWidth;
int width = Math.round(getMeasuredWidth() * scale);
int height = Math.round(getMeasuredHeight() * scale);
setMeasuredDimension(width, height);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment