What is the difference between match_parent and fill_parent?

后端 未结 17 1736
离开以前
离开以前 2020-11-22 07:37

I\'m a little confused about two XML properties: match_parent and fill_parent. It seems that both are the same. Is there any difference between the

17条回答
  •  鱼传尺愫
    2020-11-22 08:15

    match_parent, which means that the view wants to be as big as its parent (minus padding).

    wrap_content, which means that the view wants to be just big enough to enclose its content (plus padding)

    For sake of better illustration, I have created a sample layout that demonstrate this concept. To see it's effect, I added a border of each textView content.

    In "Match parent" textView content, we can see it's layout width spread out of it's parent whole length.

    But we can see in "Wrap Content" textView content, it's layout width wrapped in of it's content(Wrap Content) length.

提交回复
热议问题