<filename>app/src/main/java/net/ldvsoft/warofviruses/SquareLayout.java
package net.ldvsoft.warofviruses;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;

/**
 * Created by ldvsoft on 16.10.15.
 */
public class SquareLayout extends LinearLayout {
    public SquareLayout(Context context) {
        super(context);
    }

    public SquareLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public SquareLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int width = MeasureSpec.getSize(widthMeasureSpec);
        int height = MeasureSpec.getSize(heightMeasureSpec);
        super.onMeasure(
                MeasureSpec.makeMeasureSpec(Math.min(width, height), MeasureSpec.EXACTLY),
                MeasureSpec.makeMeasureSpec(Math.min(width, height), MeasureSpec.EXACTLY)
        );
    }
}
