Android: Transparent Colored ListViews with Background

后端 未结 3 1338
无人及你
无人及你 2021-01-14 18:05

I have a doubt I have a listview and below it there is a background with a image. I would like to have the lists with a transparent color in order to see the image in the b

相关标签:
3条回答
  • 2021-01-14 18:35

    I managed to achieve this with the RecyclerView by adding this line of code to the 'onBindViewHolder' method in the 'RecyclerView.Adapter' class:

    ((RelativeLayout) holder.itemView).getChildAt(0).setBackgroundColor(Color.parseColor("#00FFFFFF"));
    

    Bear in mind that the view returned by the above cast expression is an 'android.support.v7.widget.CardView' that contains the list item layout

    0 讨论(0)
  • 2021-01-14 18:47

    Add following property in ListView...

    android:cacheColorHint="#00000000"
    

    it is for transparent background of ListView. More detail see Here.

    0 讨论(0)
  • 2021-01-14 18:48

    You can also use an image editor to edit the opacity of the image/shape/gradient/whatever that you're using for the rows. I use Gimp because it's free. Here's what you need to do in Gimp: Go to the 'Layers - Brushes' window. Right-click the image layer and 'Add Alpha Channel'. Then just dial down the Opacity using the number picker (located above the layer) and File -> Export the image. Add this image to your project. Set it as the background for the List View rows. Then set the background for the List View itself to whatever you want to take up the entire background behind the List View.

    0 讨论(0)
提交回复
热议问题