Android listview transparent cell issue

I want to make a listview with translucent cells (something like blue with an opacity of 25%).

The list is created correctly, but when I perform a scroll movement (I click and drag up or up), the list seems to activate some sort of selection mechanism that applies a black and opaque background to the list.

Any idea how I can get rid of this?

Below is the code and two screens:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:background="@drawable/background"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/my_health_title"> </ImageView> <ListView android:id="@+id/health" android:layout_width="wrap_content" android:layout_height="wrap_content"> </ListView> 

 <TextView android:id="@+id/health_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#46727c" android:textSize="14sp" android:textStyle="bold" android:layout_marginTop="20dp" android:layout_marginLeft="30px" android:text="Blood presure Profile"> </TextView> <LinearLayout android:id="@+id/health_gauge" android:layout_width="250dp" android:layout_height="35dp" android:layout_centerVertical="true" android:layout_marginLeft="20dp"> </LinearLayout> <TextView android:id="@+id/health_description" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#46727c" android:textSize="12sp" android:textStyle="normal" android:layout_marginTop="150px" android:layout_marginLeft="30px" android:text="Looks Goood"> </TextView> <ImageView android:id="@+id/health_details" android:background="@drawable/home_arrow_icon_margin" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_centerVertical="true"> </ImageView> 

regular list

selected efect

+2
android android-listview
Mar 31 2018-11-11T00:
source share
2 answers

Just set android: cacheColorHint to # 00000000 in your ListView.

Note that the color code is an 8-digit code (#AARRGGBB), which means that the first two digits represent the alpha color. (If you set it to 6 digits, # 000000 this will not help, because it will still be opaque. For more information on color codes, click here ).

Your list view should look like this:

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

More information and explanation can be found here .

+2
Mar 31 2018-11-11T00:
source share

I had a nightmare with a similar problem. But I dynamically added ListView and

 android:cacheColorHint="#00000000" 

in this case did not work. Decision:

Do not add ListView dynamically, cacheColorHint will not work

Hope this helps someone!

+3
Nov 21 '11 at 16:31
source share



All Articles