package com.affectiva.affdexme; import android.content.Context; import android.util.AttributeSet; import android.widget.RelativeLayout; /** * Created by Alan on 7/17/2015. */ public class SquareLayout extends RelativeLayout { public SquareLayout(Context context) { super(context); } public SquareLayout(Context context, AttributeSet attrs) { this(context, attrs, 0); } public SquareLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, widthMeasureSpec); // This is the key that will make the height equivalent to its width } }