I apparently misunderstand the use of "fill" and "match" as used in the situations described in the context below.

I take "fill" to mean "taking up the empty internal volume of something, padding (wall thickness) implicitly taken into account as not available". If there is anything else in the container, "filling" will take up the space that is left (or displace the other object).

"Matching", to me, is more context dependent, and may mean equaling the internal or external dimensions (or both - "a matching set"), or a (part of) a shape. When used for volume, it may still mean internal or external, but no other objects are considered.

I am guessing some part of this is wrong. Which of my assumptions are wrong? Please offer some examples.


The question regards the terms fill_parent and match_parent (same effect, different names) in Android programming.

[edit] In short: Google have changed the name of the behavior of stretching only in the available space (which is rarely all of it) from fill_parent to match_parent. I don't see why "match" is better than "fill" to describe it.

Consider the following:

water in glass

The grey area ("glass") is a rectangle with padding on 3 sides. The blue area ("water") is inside the "glass".

If there are other elements in the "glass", asking the "water" to fill/match the "glass" may, depending on other factors, either produce the same result, or take up the remaining space.

Note that in this context, a "child view" can be larger than its parent - it will be clipped or scrolled - the parent can act more like a window than a container.

Many - Google included - insist that "match" is a more appropriate term than "fill". Here is an example of what they may find confusing ("HOW YOU CAN GET TRIPPED UP"). The XML at the end of that answer is for a red rectangle trying to "match" the height of the screen, with 2 other rectangles already there. It produces this:

trying to match height of screen

My opinion: sure, with other elements present it doesn't fill, but neither does it match. In fact, "matching the parent", to me, even more strongly suggests that it should be the same size, than "filling the parent" does. "What Google says, goes" isn't an explanation.

My deleted question on SO has more details, if you're interested. It was asking about layout logic I may have been unaware of. Here, I'm asking about the meaning of words.

The XML for my layout (glass, water)is:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:background="#9090F8" />

Chat link here.

3 Answers 3


Here is the design intent of fill_parent and match_parent, taken from your link:

Special value for the height or width requested by a View. FILL_PARENT means that the view wants to be as big as its parent, minus the parent's padding, if any.

Special value for the height or width requested by a View. MATCH_PARENT means that the view wants to be as big as its parent, minus the parent's padding, if any.

Note that the design intent is identical, all the way down to the value assigned in each case (a value of -1).

The gist of your question is:

I don't see why "match" is better than "fill" to describe it.

Fill is a term that has an established use in computer graphics:

In graphics applications, to paint the inside of an enclosed object. - webopedia

Based on this established meaning, the term FILL_PARENT sounds as if the intent is to paint the parent object, when the actual intent has nothing to do with operations on the parent. It's therefore a bad choice of words for the identifier.

On the other hand, MATCH_PARENT has the natural English meaning related to copying (but not changing) properties about the parent object, which is much closer to the design intent for that term (an excellent match for it, if you'd excuse the pun):

Match verb [with object] Be equal to (something) in quality or strength - ODO

tl;dr - FILL_PARENT implies an operation on the parent whereas MATCH_PARENT implies changing the child to resemble the parent in some way (the measurements that are to match are specified in the first quote of this answer). Since the intent is to modify the child rather than the parent, MATCH_PARENT is more suitable than FILL_PARENT.

  • Yes, I did write "same effect, different names". I know it's considered "much closer to the design intent", my question is why. Would you please clarify the last part a bit? Things to keep in mind: Padding - child views will NOT be equal in size to parent. "Sibling' rectangles will make them even smaller. From your description it feels that "fill" - implying "inside" - actually fits better than "match", which implies exact equality.
    – kaay
    Commented Apr 28, 2016 at 11:21
  • 1
    @kaay It's the difference between operating on the parent object (fill) and copying properties from the parent object (match). The implication of 'inside' isn't particularly relevant to the distinction.
    – Lawrence
    Commented Apr 28, 2016 at 14:40
  • 1
    @kaay I've added a summary to my answer that should clarify the last part, as requested.
    – Lawrence
    Commented Apr 28, 2016 at 14:44
  • Thank you. Even though such a thing has never occurred to me in the context of "setting a view's height to fill_parent", it makes sense. As I am the one with a wrong way of thinking, however, I don't feel qualified to select an answer as correct - I'll wait for other votes.
    – kaay
    Commented Apr 29, 2016 at 10:57
  • @kaay You're welcome :) . This recent meta question has some thoughts about accepting answers when in the position you describe.
    – Lawrence
    Commented Apr 29, 2016 at 11:13

You understanding seems to be confused due to a lack of connection with the geometry involved; fill here is suggestive of colouring in, rather than filling with water. You are referring to a 2d plane, the rectangle; thus it is an area and not a volume. The padding is also a two dimensional addition to the box-plane, created by the padding rules, however they were programmed.

Filling, in this context can be rather misleading, as we will easily associate this with filling a glass, as you have done; Between the 3d realm and the 2d plane however, it is quite a different thing to fill. We fill an area, think of the paint bucket tool in many graphics programs.

Now we come to match, in this particular example, to my mind, match is referring to the actual vectors of the shape, which exist in only one dimension, length is a one dimensional object as is width also; they exist each in their own dimension perpendicular to each other. When matched they are set as equal, this it is a boolean question, the response to which is either yes or no, due tho the restriction in dimension; Match can be used also in many other situations, such as a game of tennis; We could also correctly call this a tennis match; as two competitors are matched against each other. Now returning to 'fill'; Fill does not peak of the vectors that are the parents dimensions, it is a simply order that the dumb program fill until any boundary match is made; no matter what the actual vector value is.

A child may grow to be taller than their parents; Never the less their genetic code will still be a match. Two lovers my make a very good match also though this is not the most romantic of descriptions.

Your two rectangles are perfectly matched in width and height; A match made in heaven perhaps? In the cloud? Or, just in a mobile phone ...

  • vectors, yes. I should have written "1D" rather than "2D" - each "fill" ("match") is assigned to a view's single dimension. But I feel as though I was misunderstood, twice: 1. "fill until any boundary match is made" is exactly what Google prefers to call "matching the parent". 2. Yellow and black rects are not important; the red one is supposed to match_parent's height.
    – kaay
    Commented Apr 27, 2016 at 14:03
  • Remember that a mobile phone or a computer are completely and upon that totally, dumb. They look great on the outside, but their hearts are calculative and despite the great memory; they are still stupid ... You can not expect the device to interpret the semantics of correct grammatical use of the English language, it knows only that with wich it is programed, so in that light it is irrelevant which words are used. Though this is obviously impractical for the programmer, never the less, if you are a programmer; you should be able to work this one out from the way the machine is behaving ...
    – iain
    Commented Apr 27, 2016 at 15:32
  • ... not from semantics. What are the coordinate of the yellow rectangle, has it floated off screen? There is no apparent padding on the left of the screen, so might I assume that neither of the rectangles are fully visible? @kaay
    – iain
    Commented Apr 27, 2016 at 15:35
  • 1. They're all fully visible. 2. I know I'm not speaking English to the computer, both fill_parent and match_parent mean -1 to it. I'm asking why Google and others think match is a more fitting (pardon the pun) term for the behavior.
    – kaay
    Commented Apr 28, 2016 at 5:55
  • 3. This may be symptomatic of some other problem I have communicating in English - but, sticking to 1D/2D stuff only, I read your response as "You're mistaken. match is for equality only. fill is for using what's available". Problem is: that's exactly what I wrote that I assumed. Are you agreeing with me? If not, please point out what I've written that was misinterpreted.
    – kaay
    Commented Apr 28, 2016 at 6:02

I think Iain's answer is very apposite in pointing out the difference between 2D and 3D objects.

Also, having read the two articles on the Android SO that you have linked to, it seems to me that the very reason that Google are deprecating the term fill_parent in favour of match_parent is because of the very mis-understanding between the two terms that you have identified.

In other words, as I read it, Google agree with you that fill is often understood to to mean "taking up the empty internal volume"; and that if there is anything else in the container, "filling will take up the space that is left". There they are replacing it by match to avoid that confusion.

  • Yes, it is understood to mean that... and that's exactly what it does, for certain kinds of parent (inside a LinearLayout with sibling views before the "filling" one; in a RelativeLayout with e.g. "toRightOf" another). As I read your answer, they've addressed the controversy by choosing a worse substitute.
    – kaay
    Commented Apr 27, 2016 at 13:58
  • @kaay Without understanding more about what the function does in different circumstances - and I don't understand enough programming to fully understand your comments - I can't really comment further. I agree that match is not ideal, but I can see why fill is ambiguous.
    – TrevorD
    Commented Apr 27, 2016 at 14:49
  • Sorry - I mean that it feels as though you agree with my interpretation, but misread me somewhere - which led you to write "Google know fill_parent better describes the behavior of using only the empty space, and THAT is why they chose match_parent for it"
    – kaay
    Commented Apr 28, 2016 at 5:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.