The android doc here and here says:
"Must be one or more (separated by '|') of the following constant values."
How does android process multiple gravity values like "top|center_horizontal
"?
Is it that it first places the object at the top and then position is at central horizontally?
What is the difference between, say "top|left"
and "left|top"
?
Or is it that we always have to specify the vertical gravity first and then the horizontal gravity?
Nothing. Android saves flags as an int, and uses bitwise OR to add flags. So for example, say
LEFT
was defined as 1, andTOP
as 2. Then to store both, you could save 3. In binary this makes sense, you want01
and10
, so you store11
. The operation that does this trick is bitwise OR, or '|'. This operation is reflexive, soLEFT|TOP == TOP|LEFT
.