2011-11-14 41 views
0

我有一個背景圖像的相對佈局,但我想圖像填充所有的佈局空間,我認爲這是一個填充問題,我設置爲-1dip,不工作。 另外在將我的填充設置爲-1dip之前,當我用層次查看器檢查填充時。 這裏是我的xml相對佈局背景沒有填充所有空間

<RelativeLayout 
     android:id="@+id/relativeLayout2" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/gridView" 
     android:background="@drawable/tool_bar" 
     android:gravity="center" 
     > 

     <ImageView 
      android:id="@+id/imageView1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/locate" /> 

     <ImageView 
      android:id="@+id/imageView2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_toRightOf="@+id/imageView1" 
      android:src="@drawable/orbit" /> 

     <ImageView 
      android:id="@+id/imageView3" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentTop="true" 
      android:layout_toRightOf="@+id/imageView2" 
      android:src="@drawable/search" /> 

     <ImageView 
      android:id="@+id/imageView4" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_toRightOf="@+id/imageView3" 
      android:src="@drawable/snap" /> 

     <ImageView 
      android:id="@+id/imageView5" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_toRightOf="@+id/imageView4" 
      android:src="@drawable/profile" /> 
    </RelativeLayout> 
thanks 

回答

-1

我想你想圖像填充到相對佈局。 你試試吧。這可能對你有所幫助。 FILL_PARENT

<ImageView 
      android:id="@+id/any_image" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:src="@drawable/profile_you" /> 
1
如果你想通過寬度,以填補所有的空間和高度,使用FILL_PARENT或者如果你想填補一個他們喜歡的填充寬度和高度不然後設置高度WRAP_CONTENT或者如果你想

填補高度和寬度不能再設置WRAP_CONTENT到寬

喜歡這裏將填補兩個

<RelativeLayout 
     android:id="@+id/relativeLayout2" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_below="@+id/gridView" 
     android:background="@drawable/tool_bar" 
     android:gravity="center" 
     > 
</RelativeLayout> 
+0

我想要背景圖像來填充相對佈局空間。而不是相對佈局來填​​充整個屏幕 – mauriyouth

0
<RelativeLayout 
    android:id="@+id/relativeLayout2" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="@drawable/tool_bar" 
    > 

應該這樣做,我假設

2

我碰到同樣的問題。我想默認情況下,RelativeLayout不會將背景擴展到其尺寸。

結束了在下列方式使用內部的視圖:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="300px" 
android:layout_height="204px"> 
    <View 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"  
    android:background="@android:color/white"/> //Or whatever background you pick 
</RelativeLayout> 

不是解決我所期待的,但無論如何解決方案。

相關問題