1

According to the docs for the LinearLayout class for the method below:

protected LinearLayout.LayoutParams generateDefaultLayoutParams ()

Returns a set of layout parameters with a width of MATCH_PARENT and a height of WRAP_CONTENT when the layout's orientation is VERTICAL. When the orientation is HORIZONTAL, the width is set to WRAP_CONTENT and the height to WRAP_CONTENT.

I first noticed this when looking at the code and thought it might be a mistake so I looked at the doc for clarification, but found that that doc agreed with the code but with no explanation. Why is it asymmetric like this?

In other words, I'd expect a horizontal layout's default height to be the same as a vertical layout's default width and vice versa. Why is that not the case? Without explanation, it seems random and haphazard.

Don Hatch
  • 5,041
  • 3
  • 31
  • 48

0 Answers0