2013-01-05 107 views
1

當我開始我的應用程序的GridView顯示藍色背景我想設置白色背景如何設置Android Gridview顯示藍色背景,如何將背景改爲白色?

在這裏,我把我的XML和IMGE

Gridview.xml

<LinearLayout android:id="@+id/bodyfirst" 
     android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:orientation="vertical" 
      android:padding="15dp" 
     <GridView 
       android:id="@+id/gridview" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:numColumns="3" 
       android:drawSelectorOnTop="true" 
       android:gravity="center_vertical" 
       android:background="@android:color/white"> 
     </GridView> 
    </LinearLayout> 

enter image description here

+0

請提供您的項目XML – Jeetu

回答

3

你應該添加背景到LinearLayout,這段代碼是正確的,for例如

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="@android:color/white"> 
<GridView 
    android:id="@+id/gridview" 
    android:layout_width="match_parent" 
    android:layout_height="115px" 
    android:numColumns="3" 
    android:drawSelectorOnTop="true" 
    android:gravity="center_vertical" 
    android:background="@android:color/holo_blue_dark" /> 
<GridView 
    android:id="@+id/gridview" 
    android:layout_width="match_parent" 
    android:layout_height="100px" 
    android:numColumns="3" 
    android:drawSelectorOnTop="true" 
    android:gravity="center_vertical" 
    android:background="@android:color/holo_blue_dark" 
    android:layout_marginTop="13.0dp" /> 
    </LinearLayout> 

,你應該添加xmlns:android="http://schemas.android.com/apk/res/android"到的LinearLayout enter image description here