android – What is the difference between match_parent and fill_parent?


When I'm editing the xml layout I'm always confused when choosing between match_parent and fill_parent , and I always end up thinking that I'm doing everything wrong because I don't know what each one is or if they are the same.

Could someone explain what the functionality of each one is?


What is the difference between match_parent and fill_parent ?

They are the same thing (at API Level 8+).

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

fill_parent was renamed to match_parent as the problem with the old name was that it implied affecting the dimensions of the parent , while match_parent better described the resulting behavior – matching the dimension with the parent .

What does match_parent do?

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

Use match_parent as there is no difference if you are on API versions 8+, and since cell phones => Android 2.2 it is advisable to use match_parent , but for compatibility reasons for previous versions there is still fill_parent .

NOTE: 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 API versions use fill_parent .

According to the official Android documentation, it specifies that they are the same thing and that there is no difference in using one or the other.

Scroll to Top