Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@hrules6872
Last active June 10, 2016 12:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hrules6872/7a18862b55f7b6db5da1 to your computer and use it in GitHub Desktop.
Save hrules6872/7a18862b55f7b6db5da1 to your computer and use it in GitHub Desktop.
SquareRelativeLayout
public class SquareRelativeLayout extends RelativeLayout {
public SquareRelativeLayout(Context context) {
this(context, null);
}
public SquareRelativeLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public SquareRelativeLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int measureSpecSize = MeasureSpec.getSize(widthMeasureSpec);
this.setMeasuredDimension(measureSpecSize, measureSpecSize);
super.onMeasure(widthMeasureSpec, widthMeasureSpec);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment