Listview背景在Android中不显示

| 我的可绘制文件夹中有一个名为bg.png的项目,但是,它不会在列表视图中显示为背景。我得到的只是默认的黑色。我究竟做错了什么?是否需要特定大小,还是我的代码有问题?参见下面的main.xml:
<LinearLayout android:id=\"@+id/LinearLayout01\"
    xmlns:android=\"http://schemas.android.com/apk/res/android\"
    android:layout_height=\"fill_parent\"
     android:layout_width=\"fill_parent\"
     android:background=\"@drawable/bg\">

<ListView android:id=\"@+id/ListView01\"
android:layout_width=\"wrap_content\"
android:layout_height=\"wrap_content\"
android:background=\"#00000000\"
android:cacheColorHint=\"#00000000\">

</ListView>

</LinearLayout>
    
已邀请:
        好的,使用下面的代码,它将起作用。
<LinearLayout android:id=\"@+id/LinearLayout01\"
xmlns:android=\"http://schemas.android.com/apk/res/android\"
android:layout_height=\"fill_parent\"
 android:layout_width=\"fill_parent\">

<ListView android:id=\"@+id/ListView01\"
android:layout_width=\"wrap_content\"
android:layout_height=\"wrap_content\"
android:background=\"@drawable/bg\">

</ListView>
</LinearLayout>
    
        这里的问题可能是您还需要将列表视图项目的背景色设置为此颜色,因为显示项目时,显示的颜色是列表视图项目的背景色,而不是列表视图本身。     

要回复问题请先登录注册