如何在listview中添加背景? -Android

问题描述 投票:0回答:1

我有一个listview活动,包含一堆单个textview项。这是我的项目:

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/label"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:textColor="#FFFFFF"
    android:background="#00000000"
    android:padding="10dip"
    android:textSize="16dip"
    android:textStyle="bold" >    
</TextView>

如您所见,文本颜色为白色,背景为透明。 (我尝试将alpha从0增加到100,它显示白色背景或黑色)

现在在listview中,我在后台放了一个名为“s4”的图片:

<ListView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/llll"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    android:background="@drawable/s4">
</ListView>

我想让listview项目变得半透明,以便可以查看背景图像。

每个项目应该是半透明的,文本应该是白色和可见的,并且列表视图的背景应该是可见的。

我似乎无法做到正确,我可以放一个纯色,但我希望项目滚动固定的背景图像。

我究竟做错了什么? (有几个这样的问题,但都没有解决。)

编辑:

http://postimg.org/image/4yjh7fiwp/

这是屏幕,看得非常紧密,你可以看到文字,(尝试按CTRL + A)但文字的颜色不是问题,白色文字很好,因为我的背景图像是黑色的......我只是想要列表视图,它是物品是半透明的。

这个屏幕与我所做的几乎完全一样,并且由swapnil给出的建议......根本没有变化。

android image list view colors
1个回答
0
投票

确保列表backdrnd不会白色其他明智的文本将不可见。

<ListView
        android:id="@+id/lvSongs"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:cacheColorHint="@android:color/transparent"
        android:listSelector="@android:color/transparent"
        android:padding="10dp" 
        android:background="@drawable/s4"
/>

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/label"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:textColor="@android:color/white"
    android:background="@android:color/transpernt"
    android:padding="10dip"
    android:textSize="16dip"
    android:textStyle="bold" >    
</TextView>
© www.soinside.com 2019 - 2024. All rights reserved.