Created
October 11, 2016 07:32
-
-
Save LouisCAD/fa4febfe1f72d16315e2ddf0210845fc to your computer and use it in GitHub Desktop.
Makes any view square
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Ensures the view is square by making it the size of the smallest side. | |
*/ | |
@Override | |
protected final void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { | |
super.onMeasure(widthMeasureSpec, heightMeasureSpec); | |
int size = Math.min(getMeasuredWidth(), getMeasuredHeight()); | |
setMeasuredDimension(size, size); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment