Question
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.
Context:
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:
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:
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:id="@+id/glass"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="30dip"
android:paddingLeft="30dip"
android:paddingRight="30dip"
android:background="#B0B0B0">
<View
android:id="@+id/water"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#9090F8" />
</LinearLayout>