public void onResponse(.....){ //do stuff with data mAdapter.notifyDataSetChanged(); } ScrollView -> normal LinearLayout(MATCH, WRAP, vertical) -> custom SizeCappedLinearLayout(MATCH, WRAP, horizontal) View heightLink = activ.findViewById(R.id.someHeaderView); SizeCappedLinearLayout scrollLine = new SizeCappedLinearLayout(activ); scrollLine.setHeightLink(heightLink); scrollLine.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); scrollLine.setOrientation(LinearLayout.HORIZONTAL); public class SizeCappedLinearLayout extends LinearLayout { private View widthLink = null; private View heightLink = null; public SizeCappedLinearLayout(Context context) { super(context); } protected void setWidthLink(View v) { widthLink = v; } protected void setHeightLink(View v) { heightLink = v; } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { if(widthLink != null) { heightMeasureSpec = getLinkedSpec(widthLink.getMeasuredHeight(), widthLink.getHeight()); } if(heightLink != null) { heightMeasureSpec = getLinkedSpec(heightLink.getMeasuredHeight(), heightLink.getHeight()); } super.onMeasure(widthMeasureSpec, heightMeasureSpec); } private int getLinkedSpec(int measureDim, int dim) { if(dim > 0) { return MeasureSpec.makeMeasureSpec(dim, MeasureSpec.AT_MOST); } else { return MeasureSpec.makeMeasureSpec(measureDim, MeasureSpec.AT_MOST); } } }