8

What was the reason behind introducing match_parent and deprecating fill_parent since both mean the same thing. won't this change be a hindrance to backward compatibility?

1O1
  • 713
  • 10
  • 15
  • I always wondered about this too. I actually think `fill_parent` represents the meaning better than `match_parent`. – inazaruk Sep 30 '11 at 09:12

2 Answers2

10

Using match_parent instead of fill_parent will NOT make the generated APK unrunnable in older versions because in the generated APK the occurrence of match_parent's and fill_parent's will be replaced with their corresponding Constant Value, which is same in this case (both are -1), so same APK can run on older versions of Android platform as well.

But while compiling the code if you switch to older version (version 7 or below) then you will get a compilation error (since match_parent is not defined in version 7 or below).

1O1
  • 713
  • 10
  • 15
4

Android Doc says:

FILL_PARENT (renamed MATCH_PARENT in API Level 8 and higher), which means that the view wants to be as big as its parent (minus padding)

fill_parent: The view should be as big as its parent (minus padding). This constant is deprecated starting from API Level 8 and is replaced by match_parent.

So They are the same as their values are both -1. But if you worry about the backward compatibility, you can go here: platfrom version

this give you a better idea on when you should change all your fill_parent to match_parent. as of now, it seems 50% ppl are using API Level 8 or above. So it's up to you to change it.

Community
  • 1
  • 1
Terence Lui
  • 2,778
  • 1
  • 18
  • 17
  • Thanks for the reply, but my question was why this change was done and not how to get along with it. – 1O1 Sep 30 '11 at 18:23
  • I am sorry, the only reason I can come up with is FILL_PARENT may mean fill the child view to its parent view at the same size and location(x, y). But the actually meaning of FILL_PARENT is the size( either width or height) is same as the parent, not the location(x, y), so they decided to change to MATCH_PARENT for a clarification on this. But I am not the one who changed the name of this, just take a reasonable guess on it. :) – Terence Lui Oct 03 '11 at 01:04