Here’s a simple example:



  

  
    
  


(You may want to throw that whole block in a ScrollView for more obvious results)

So what you have above is pretty straightforward. You have a container with wrap_content for height. It has 2 children, one is at a fixed height of 10000dp, and the other is set to match_parent. As expected, the parent is expanded to 10000dp in height, as you can see by the red background. However, the second sibling, whose height should “match parent”, clearly does not do that – you’ll notice the orange background of that second sibling exists only as tall enough as is required to render the TextView.

There are simple ways around this – for example, you could write a LargestChildLayout pretty simply:

public class LargestChildLayout extends ViewGroup {

  private int mWidth;
  private int mHeight;

  public LargestChildLayout(Context context) {
    super(context);
  }

  public LargestChildLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
  }

  public LargestChildLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
  }

  @Override
  protected void onLayout(boolean changed, int l, int t, int r, int b) {
    for (int i = 0; i < getChildCount(); i++) {
      View child = getChildAt(i);
      child.layout(0, 0, mWidth, mHeight);
    }
  }

  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    measureChildren(widthMeasureSpec, heightMeasureSpec);
    for (int i = 0; i < getChildCount(); i++) {
      View child = getChildAt(i);
      mWidth = Math.max(mWidth, child.getMeasuredWidth());
      mHeight = Math.max(mHeight, child.getMeasuredHeight());
    }
    setMeasuredDimension(mWidth, mHeight);
  }

}

Or if you wish to use provided components, a ConstraintLayout can achieve it as well:



  

  
    
  


I suspect a RelativeLayout might work as well, with layout_alignParentTop and layout_alignParentBottom both set to true, but haven't tried.