2015-07-03 36 views
0

我不能夠得到之所以有以下兩種觀點的差異,唯一的區別是layout_gravity 中心在第二個layout_gravity中心連同layout_marginRight問題

<?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" 
     /> 

enter image description here

<?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" 
     /> 
失蹤

enter image description here

回答

2

當你在做安卓:layout_gravity = 「頂|中心」我認爲margin_right正在去視圖向左

enter image description here

莫非是嗎?

編輯

我用你的代碼,看看,這就是結果 enter image description here

+0

它可能是這樣,但我不知道.. – Akhil

-1

enter image description here

這裏是我的疑問句。

Reason behind extra 8dp margin in a view ? not ways to solve

下我的話有下劃線..

  • I表示它作爲與黑色背景的圖。
  • 左邊48dp。
  • 但是,正如你所看到的,還有一個額外的8dp。
  • 我正在尋找一個真正的原因。
  • 沒有其他方法來整理它。
  • 查看我的鏈接瞭解更多詳情。