简体   繁体   中英

Android: ListView Background color not applying to the whole listview

I have a custom ListView and I am trying to apply a background color on it but it only applies on the area where there is no list Item. I have tried many techniques but it won't working for me. I want to make the background color on the whole listview please help me how to achieve it. Here is my XML code

<ListView 
                android:layout_height="fill_parent"
                android:layout_width="match_parent"
                android:id="@+id/user"
                android:scrollingCache="false"
                android:scrollbars="none"
                android:cacheColorHint="#00000000"
                android:background="@android:color/darker_gray"
                android:overScrollMode="never"
                android:layout_below="@+id/sub_title">

            </ListView>

This is its result

在此处输入图片说明

And this is what i want

在此处输入图片说明

Try using a transparent background color for your ListView items' layout, or use the same background color on your list items.

For the transparent background solution, you can apply this in your item's xml file

android:background="@android:color/transparent"

Please use like this

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/brown"
    tools:context=".MainActivity" >

    <ListView
        android:id="@+id/programsLV"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    </ListView>



</RelativeLayout>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM