我无法理解为什么在以下两个视图中存在差异,唯一的不同是layout_gravity center在第二个视图中缺失。
<?xml version="1.0" encoding="utf-8"?>
<View
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_gravity="top|center"
android:layout_height="10dp"
android:layout_marginRight="100dp"
android:background="@android:color/holo_red_dark"
/>

<?xml version="1.0" encoding="utf-8"?>
<View
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_gravity="top"
android:layout_height="10dp"
android:layout_marginRight="100dp"
android:background="@android:color/holo_red_dark"
/>

发布于 2015-07-03 18:11:20
当你在做android:layout_gravity="top|center"时,我认为margin_right正在使视图向左转

会是这样吗?
编辑的
我使用您的代码查看,这就是结果

发布于 2015-07-04 04:14:37

这是我的行李。
Reason behind extra 8dp margin in a view ? not ways to solve
在我的话下有一个下划线。
https://stackoverflow.com/questions/31212020
复制相似问题