Android Gridview显示蓝色背景,如何将背景更改为白色?

时间:2013-01-05 08:58:46

标签: android gridview background

当我开始我的应用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

1 个答案:

答案 0 :(得分:3)

您应该向LinearLayout添加背景,此代码是正确的,例如

<?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