2014-01-15 99 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为布局内的元素。但我需要知道为什么布局正在被削减。 –