在代码中重新计算出每个item的高度
public void setListViewHeightBasedOnChildren(GridView gridView) {
return;
}
int totalHeight = 0;
for (int i = 0; i < (secondHouseList.size()); i++) {
View listItem = secondHouseApdater.getView(i, null, gridView);
listItem.measure(0, 0);
totalHeight += listItem.getMeasuredHeight();
}
ViewGroup.LayoutParams params = gridView.getLayoutParams();
params.height = totalHeight;
((ViewGroup.MarginLayoutParams) params).setMargins(15, 15, 15, 15);
gridView.setLayoutParams(params);
}