2015-03-08 73 views
1

我有這樣一個問題:如何對齊RelativeLayout的帶空白0

如何對齊RelativeLayout對準在以下情況下左右,上?

enter image description here

我想刪除此空白,並在屏幕使藍色和黃色RelativeLayout

這裏是我的佈局:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:background="#EAEAEA" > 

    <RelativeLayout 
     android:id="@+id/layout_cenas_bottom" 
     android:layout_width="match_parent" 
     android:layout_height="50dp" 
     android:layout_alignParentBottom="true" 

     android:background="#FFFF00" > 

     <Button 
       android:id="@+id/btnAdicionarCenas" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:text="@string/title_adicionar_cena" 
       android:layout_weight="1" 
       android:background="@drawable/mybutton" 
       android:textColor="@drawable/mybuttoncolors" 
       android:textSize="15sp" 
       android:layout_marginBottom="10dp"> 
      </Button> 

    </RelativeLayout> 

    <RelativeLayout 
     android:id="@+id/layout_cenas_conteudo" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_above="@id/layout_cenas_bottom" 
     android:layout_alignParentTop="true" 
     android:background="#00FFFF"> 

    <ListView 
     android:id="@+id/lvCenas" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" > 
    </ListView> 

    </RelativeLayout> 


</RelativeLayout> 
+0

您試圖對齊哪種佈局? – JonasCz 2015-03-08 19:38:20

+0

我試圖填充左側,右側,頂部和底部的空白區域。隨着佈局。我清楚了嗎? – 2015-03-08 19:41:33

+0

是否將此佈局添加到活動的主佈局? – gyosida 2015-03-08 19:42:24

回答

1

看起來像你的佈局是活動佈局的一部分。因此,請檢查您的主要活動是否具有android:paddingXXX params的主佈局並將其刪除。

+0

是的男人!非常感謝你!它解決了我的問題! – 2015-03-08 19:42:36

0

照照dimens.xml,如果你有這樣的事情:

<dimen name="activity_horizontal_margin">8dp</dimen> 
<dimen name="activity_vertical_margin">4dp</dimen> 

檢查您的佈局(或父佈局)使用它們,例如:如果是,那麼

android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingBottom="@dimen/activity_vertical_margin" 

刪除它們或將dimens.xml中的值更改爲0dp。

相關問題