Skip to content

Instantly share code, notes, and snippets.

@GlebMaltsev
Created February 12, 2016 14:37
Show Gist options
  • Save GlebMaltsev/e882d16a09183b59ba21 to your computer and use it in GitHub Desktop.
Save GlebMaltsev/e882d16a09183b59ba21 to your computer and use it in GitHub Desktop.
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int width = getMeasuredWidth();
int height = getMeasuredHeight();
int measureSpec = keepAspectRatioByHeight ? height : width;
// ViewGroup.LayoutParams params = this.getLayoutParams();
// params.height = measureSpec;
// params.width = measureSpec;
// this.setLayoutParams(params);
setMeasuredDimension(measureSpec, measureSpec);
// int measureSpec = keepAspectRatioByHeight ? heightMeasureSpec : widthMeasureSpec;
// super.onMeasure(measureSpec, measureSpec);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment