1, if the use of android:layout_marginright in LinearLayout does not work, by testing the original in android2.x, if a control has a android:layout_gravity property, will appear android:layout_marginright did not have the effect, but the left margin to the right margin up, directly remove the Android:layout_gravity this attribute can be resolved
2, if it does not work in the relativelayout, please add a android:layout_alignparentright= "true" in front of this code, the line ( self-verification success )
3, if the ScrollView in the LinearLayout set the margin class property is invalid, the workaround linearlayout add android:layout_gravity= "Top" property is OK,
4, if it is lineaerlayout put into the ScrollView or relativelayou inside the Layout_margin failure does not work, the solution in the attribute added android:layout_gravity= "Top", Note that 1 is not the same, 1 is linearlayout inside the control, and here refers to linearlayout in other controls, please distinguish between the treatment.
5. I placed a relativelayout in a relativelayout, and the layout_margintop in this relativelayout has not worked, It was later discovered because my outermost relativelayout added another android:gravity= "center" that caused the problem
It doesn't know if it's a bug or something.
Above content reproduced from: http://blog.csdn.net/lovexieyuan520/article/details/10499811
----My experience:
I want to add a layout to a actionmode, as follows
<LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:id= "@+id/navigation_bar"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "Horizontal"> <RelativelayoutAndroid:layout_margintop= "26DP"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"> <ButtonAndroid:id= "@+id/cancel"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:layout_marginleft= "10DP"android:layout_centervertical= "true"android:src= "@drawable/fm_return_selector" /> <TextViewAndroid:id= "@+id/select"Android:layout_height= "Wrap_content"Android:layout_width= "Wrap_content"Android:layout_torightof= "@+id/cancel"Android:layout_alignparentright= "true"android:textsize= "13SP"Android:textcolor= "#ffffff" /> <ButtonAndroid:id= "@+id/detail"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"android:layout_centervertical= "true"Android:layout_marginright= "10DP"Android:layout_alignparentright= "true"android:src= "@drawable/action_mode_detail" /> </Relativelayout> </LinearLayout>
The results found that the text will never center, and then finally found the problem, the original torightof means that your control to the left side of the control with the other side of the alignment, if you do not add layout_marginleft, then the distance between two is zero, that is, the so-called strict alignment. Moreover, his priority seems to be higher than android:layout_alignparentright= "true", which is why it does not work, as long as the Torightof this attribute is removed, the problem is solved.
Linearlayout-margin Non-functional handling