Skip to content

Instantly share code, notes, and snippets.

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (maxWidth > 0 && maxWidth < MeasureSpec.getSize(widthMeasureSpec)) {
widthMeasureSpec = MeasureSpec.makeMeasureSpec(maxWidth, MeasureSpec.AT_MOST);
} else if (minWidth > 0 && minWidth > MeasureSpec.getSize(widthMeasureSpec)) {
widthMeasureSpec = MeasureSpec.makeMeasureSpec(minWidth, MeasureSpec.EXACTLY);
}
if (maxHeight > 0 && maxHeight < MeasureSpec.getSize(heightMeasureSpec)) {
heightMeasureSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST);
} else if (minHeight > 0 && minHeight > MeasureSpec.getSize(widthMeasureSpec)) {