Skip to content

Instantly share code, notes, and snippets.

@GlebMaltsev
Created February 12, 2016 16:05
Show Gist options
  • Save GlebMaltsev/6071e90d63b0de893d90 to your computer and use it in GitHub Desktop.
Save GlebMaltsev/6071e90d63b0de893d90 to your computer and use it in GitHub Desktop.
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
Log.d("onMeasure", "...");
int width = getMeasuredWidth();
int height = getMeasuredHeight();
int size = keepAspectRatioByHeight ? height : width;
Log.d("Image onMeasure", "MeasureSpec.getSize(widthMeasureSpec) = " + MeasureSpec.getSize(widthMeasureSpec));
Log.d("Image onMeasure", "MeasureSpec.getSize(heightMeasureSpec) = " + MeasureSpec.getSize(heightMeasureSpec));
setMeasuredDimension(size, size);
// int size = keepAspectRatioByHeight ? heightMeasureSpec : widthMeasureSpec;
// super.onMeasure(size, size);
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
Log.d("Image onLayout", "...");
Log.d("Image onLayout", "changed = " + changed);
Log.d("Image onLayout", "left = " + left);
Log.d("Image onLayout", "top = " + top);
Log.d("Image onLayout", "right = " + right);
Log.d("Image onLayout", "bottom = " + bottom);
Log.d("Image onLayout", "right - left = " + (right - left));
Log.d("Image onLayout", "bottom - top = " + (bottom - top));
}@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
Log.d("onMeasure", "...");
int width = getMeasuredWidth();
int height = getMeasuredHeight();
int size = keepAspectRatioByHeight ? height : width;
Log.d("Image onMeasure", "MeasureSpec.getSize(widthMeasureSpec) = " + MeasureSpec.getSize(widthMeasureSpec));
Log.d("Image onMeasure", "MeasureSpec.getSize(heightMeasureSpec) = " + MeasureSpec.getSize(heightMeasureSpec));
setMeasuredDimension(size, size);
// int size = keepAspectRatioByHeight ? heightMeasureSpec : widthMeasureSpec;
// super.onMeasure(size, size);
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
Log.d("Image onLayout", "...");
Log.d("Image onLayout", "changed = " + changed);
Log.d("Image onLayout", "left = " + left);
Log.d("Image onLayout", "top = " + top);
Log.d("Image onLayout", "right = " + right);
Log.d("Image onLayout", "bottom = " + bottom);
Log.d("Image onLayout", "right - left = " + (right - left));
Log.d("Image onLayout", "bottom - top = " + (bottom - top));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment