What is the difference between match_parent and fill_parent?

Asked

Viewed 6,185 times

10

When I am editing the xml layout I always get confused when choosing between the match_parent and the fill_parent, and I always end up thinking I’m doing everything wrong because I don’t know what each one of them is or if they’re the same.

One could explain the functionality of each?

4 answers

15


What is the difference between match_parent and fill_parent ?

They are the same (in Level API 8+).

Yes, MATCH_PARENT and FILL_PARENT are just different constant names for the same integer value (-1 if you are curious) used to specify the layout mode of a View within your parent.

The fill_parent was renamed to match_parent because the problem with the old name was that it implied to affect the dimensions of the parent, while match_parent best described the resulting behaviour - the dimension corresponding to the parent.

What is the match_parent function ?

The function of match_parent is to give a special value to the height or width requested by a View.

Use match_parent because there is no difference if you are in versions of API 8+,and since mobile phones => Android 2.2 is advisable to use match_parent,but because of compatibility for previous versions still exists fill_parent.

OBS : In Android API versions from 1.6 to 2.1 it is advisable to use fill_parent because using match_parent in these versions certain errors occur, so in these versions of API use fill_parent.

According to the official documentation of Android itself, it specifies that are the same thing and that there is no difference in using either.

https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html

  • I appreciate the detailed explanation, I think I’m going to have to make a lot of changes so now, on the right track. =)

2

The fill_parent is no longer used, it is obsolete.

It was replaced by match_parent, you can even use the fill_parent, but it can happen some "defects" in the application.

Then it is better to use the current one which is the macth_parent.

2

Basically, nothing. They’re both the same thing. Documentation link here

fill_parent was renamed to match_parent in API 8 and larger. Always try using match_parent

2

Browser other questions tagged

You are not signed in. Login or sign up in order to post.