Skip to content

Instantly share code, notes, and snippets.

@GlebMaltsev
Created February 12, 2016 15:58
Show Gist options
  • Save GlebMaltsev/9689c97824c5a13dce41 to your computer and use it in GitHub Desktop.
Save GlebMaltsev/9689c97824c5a13dce41 to your computer and use it in GitHub Desktop.
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
Log.d("onMeasure", "...");
Log.d("onMeasure", "...");
int width = getMeasuredWidth();
int height = getMeasuredHeight();
int measureSpec = keepAspectRatioByHeight ? height : width;
Log.d("onMeasure", "getMeasuredWidth() = " + width);
Log.d("onMeasure", "getMeasuredHeight() = " + height);
// 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);
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
Log.d("onLayout", "...");
Log.d("onLayout", "...");
Log.d("onLayout", "changed = " + changed);
Log.d("onLayout", "left = " + left);
Log.d("onLayout", "top = " + top);
Log.d("onLayout", "right = " + right);
Log.d("onLayout", "bottom = " + bottom);
Log.d("onLayout", "right - left = " + (right - left));
Log.d("onLayout", "bottom - top = " + (bottom - top));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment