2014-01-15 139 views
1

我有一個relativelayout與2 ImageButtons和2 spinner。所有的都是aligne垂直居中。現在當paddingBottomrelativelayout旋鈕和按鈕被切斷。按鈕和旋鈕的底部不會在這裏被切斷。android添加填充佈局削減佈局中的項目

enter image description here

這是我的代碼

<RelativeLayout 
      android:id="@+id/rellayout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:layout_centerHorizontal="true" 
      android:paddingBottom="20dp"> 

      <ImageButton 
       android:id="@+id/imgshare" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       android:layout_centerVertical="true" 
       android:background="@android:color/transparent" 
       android:paddingRight="5dp" 
       android:src="@drawable/share" /> 

      <ImageButton 
       android:id="@+id/imageButtonLocation" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerVertical="true" 
       android:background="@android:color/transparent" 
       android:padding="5dp" 
       android:src="@drawable/location_icon" /> 

      <Spinner 
       android:id="@+id/spnrprivacy" 
       android:layout_width="100dp" 
       android:layout_height="30dp" 
       android:layout_centerVertical="true" 
       android:layout_marginLeft="5dp" 
       android:layout_toRightOf="@id/imageButtonLocation" 
       android:background="@drawable/dropdown" /> 

      <Spinner 
       android:id="@+id/spnrtitbits" 
       android:layout_width="100dp" 
       android:layout_height="30dp" 
       android:layout_centerVertical="true" 
       android:layout_marginLeft="5dp" 
       android:layout_toRightOf="@id/spnrprivacy" 
       android:background="@drawable/dropdown" /> 
     </RelativeLayout> 

沒有人知道爲什麼會這樣?

+1

請粘貼相關佈局的屬性 – Michal

+0

添加屬性是相對佈局 –

+0

所以你應該使用wrap_content的微調因爲它只是不能適應30dp或使用自定義繪製背景的微調這將適合30dp – Michal

回答

0

更改旋鈕的固定高度"30dp"並將其設置爲wrap_content。這種行爲可能不同的設備

ANS:

而不是PaddingBottom於母公司可以設置MarginBottom像孩子的微調。沒有屬性RelativeLayout多數民衆贊成我可以建議

+0

是的,我知道我可以使用MarginBottom爲佈局內的元素。但我需要知道爲什麼佈局正在被削減。 –