问题
I am not able to get reason why there is difference in below two views, only difference is layout_gravity center is missing in second one
<?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"
/>

回答1:
When you're doing android:layout_gravity="top|center" I think that margin_right is making go the view to the left

Could that be it?
Edited
I used your code to see and this is the result

回答2:

here is my ques.
Reason behind extra 8dp margin in a view ? not ways to solve
under my words there is an underline..
- i represented it as a view with black background.
- with leftmargin of 48dp.
- but as you see there is an 8dp extra.
- i am looking for a genuine reason.
- not other ways to sort it out.
- check my link for further details.
来源:https://stackoverflow.com/questions/31212020/layout-gravity-center-along-with-layout-marginright-issue