我无法理解为什么以下两个视图存在差异,只有差异是第二个缺少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"
/>
答案 0 :(得分:2)
当你在做 android:layout_gravity =“top | center”时,我认为 margin_right 正在向左转移视图
可能是吗?
<强>被修改
我用你的代码看,这是结果
答案 1 :(得分:-1)
这是我的问题。
Reason behind extra 8dp margin in a view ? not ways to solve
在我的话下有一个下划线..