自定义ListView 、GradView 重写onMeasure方法让其正确显示

1 继承原始的

2 重写onMeasure方法

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
  MeasureSpec.AT_MOST);
  super.onMeasure(widthMeasureSpec, expandSpec);
}

原文地址:https://www.cnblogs.com/exayong/p/6617222.html