package com.mfh.comna.view;
import android.content.Context;
import android.util.AttributeSet;
import android.view.ViewGroup;
import android.widget.GridView;
/**
* Created by Shicy on 14-4-11.
*/
public class ExpandGridView extends GridView {
public ExpandGridView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (getLayoutParams().height == ViewGroup.LayoutParams.WRAP_CONTENT) {
// Calculate entire height by providing a very large height hint.
// View.MEASURED_SIZE_MASK represents the largest height possible.
int expandSpec = MeasureSpec.makeMeasureSpec(MEASURED_SIZE_MASK, MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
}
else {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
}