@Override public void onMeasure(int widthMeasureSpec,int heightMeasureSpec){
  int measuredWidth=MeasureSpec.getSize(widthMeasureSpec);
  int widthMode=MeasureSpec.getMode(widthMeasureSpec);
  int measuredHeight=MeasureSpec.getSize(heightMeasureSpec);
  int heightMode=MeasureSpec.getMode(heightMeasureSpec);
  int minDimension=Math.min(measuredWidth,measuredHeight);
  super.onMeasure(MeasureSpec.makeMeasureSpec(minDimension,widthMode),MeasureSpec.makeMeasureSpec(minDimension,heightMode));
}

@ Override public void onMeasure ( int widthMeasureSpec , int heightMeasureSpec ) { int measuredWidth = MeasureSpec . getSize ( widthMeasureSpec ) ; int widthMode = MeasureSpec . getMode ( widthMeasureSpec ) ; int measuredHeight = MeasureSpec . getSize ( heightMeasureSpec ) ; int heightMode = MeasureSpec . getMode ( heightMeasureSpec ) ; int minDimension = Math . min ( measuredWidth , measuredHeight ) ; super . onMeasure ( MeasureSpec . makeMeasureSpec ( minDimension , widthMode ) , MeasureSpec . makeMeasureSpec ( minDimension , heightMode ) ) ; }
measure the view to end up as a square , based on the minimum of the height and width .
