簡體   English   中英

Android:ListView背景顏色不適用於整個ListView

[英]Android: ListView Background color not applying to the whole listview

我有一個自定義ListView,我試圖在其上應用背景色,但它僅適用於沒有列表項的區域。 我嘗試了很多技術,但對我不起作用。 我想使整個listview的背景顏色,請幫助我如何實現它。 這是我的XML代碼

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

這是它的結果

在此處輸入圖片說明

這就是我想要的

在此處輸入圖片說明

嘗試為ListView項的布局使用透明的背景色,或在列表項上使用相同的背景色。

對於透明背景解決方案,您可以在項目的xml文件中應用它

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

請這樣使用

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM