2016-11-13 83 views
-1

如果layout_centerVertical或layout_centerInParent爲true,則在RelativeLayout中,垂直邊距(margin top,margin bottom)不適用於我?RelativeLayout和垂直邊距(保證金頂部,保證金底部)不適合我爲什麼?

<RelativeLayout>` 
` 
    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerVertical="true" 
     android:layout_marginTop="900dp" 
     android:background="#36648b" 
     android:src="@drawable/ic_star_black_24dp" 
     /> 

</RelativeLayout>` 

enter image description here

+0

你想做什麼? –

+0

@Zeeshan Shabbir我只是試試 – ahmedsamir09

回答

0

當你layout_centerInParent="true"您的ImageView,它被放在恰好父視圖的中心。

layout_marginTop="[##]dp"將影響您的佈局,如果一個對象在您的視圖的頂部90px內。因此,推動居中視圖以保持至少90px的空間。所以它不會被忽略,但它不會產生你認爲它應該具有的效果。

來源:https://stackoverflow.com/a/7895380/5244435