自定义GridView重写 onMeasure方法
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
}
MeasureSpec.AT_MOST:使用measureSpec中size的值作为最大值,采用不超过这个值的最大允许值