What is the difference between the layout_gravity attribute and the gravity attribute of wirelessly?
The LinearLayout has two very similar properties:
Android:gravity and Android:layout_gravity.
The difference between them is:
The Android:gravity property is the qualification for the content in the view. For example, a button above the text. You can set the text relative to the view's left, right, and so on.
Android:layout_gravity is used to set the location of the view relative to the parent view. For example, a button in the LinearLayout, you want to put the button in the LinearLayout left, on the right and so on can be set by this property.
That is, android:gravity is used to set the alignment of content in view relative to the view component, while android:layout_gravity is used to set the alignment of the view component with respect to the container.
The principle is a bit similar to Android:paddingleft and Android:layout_marginleft. If both properties are set at the same time on the button.
Android:paddingleft= the content set on the 30px button is 30 pixels from the left edge of the button
Android:layout_marginleft= "30px" The entire button is set from the left side of the content 30 pixels
The difference between layout_gravity and gravity in Android