Set the layout_height of the layout to wrap_content, and LinearLayout or Relative can also be set to wrap_content.