I have a custom `Linearlayout` that combines some views together. I want this `Linearlayout` to be `wrap_content` for the height. I tried adding layout params in the custrucor like this

```
LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, 
                                       ViewGroup.LayoutParams.WRAP_CONTENT);
setLayoutParams(params);

```

but it has no effect. the height is still `match_parent`. I also tried to calculate height in `onMeasure` based on the height of children like this

```
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    measureChildren(widthMeasureSpec,heightMeasureSpec);
    int size = 0;
    for(int i = 0; i <getChildCount();i++) {
        size += getChildAt(i).getMeasuredHeight();
    }
    int height = resolveSize(size,heightMeasureSpec);
    setMeasuredDimension(widthMeasureSpec,height);
}

```

It also does not have any effect. So where is the problem?