Any attribute prefixed by layout_ is an attribute of LayoutParams . Although most of the attributes of the view are analyzed during the construction of the view by the view itself, LayoutParams are special arguments to the parent view that provide hints on how the parent should determine the size and position of the child view. Which LayoutParams are valid for the view depends entirely on the type of the parent view.
layout_margin is an instruction for a parent view that supports fields. It says: "Put this much space between me and other looks or the edge of the parent." A spacer is the space inside the edge of a view and its contents.
layout_gravity - gravity for one child inside his parent. gravity affects the contents of the displayed view.
Which one you use depends on the result you want to achieve. If you want the layout to have a fixed space between its edges and all the content, you want to fill. If you want to move the layout of your borders to a certain distance, you need fields. When you have layouts without a background set, the two can be visually equivalent. When you start creating sophisticated user interfaces, where layouts have backgrounds with 9 patches that visually group content, the differences become apparent.
adamp
source share