In my application, I apply the transparent background to my ListView
's CustomListItem at runtime. For that I use, convertView.setBackgroundColor(android.R.color.transparent);
. It works and shows transparency. But that is not fully transparent as there is some kind of shade to the background. I also tried putting my own transparent color with the values #80000000
and #00000000
but the result is worse. What can I do to get the fully transparent color?
Asked
Active
Viewed 3.2k times
11

Rajkiran
- 15,845
- 24
- 74
- 114
5 Answers
27
Set this attribute to your listview in xml file
android:background="@android:color/transparent"
and also apply the transparent background to your ListView's CustomListItem at runtime. For that you have use,
convertView.setBackgroundColor(Color.TRANSPARENT);
Thanks

Kumar Bibek
- 9,016
- 2
- 39
- 68

Zumbarlal Saindane
- 1,199
- 11
- 24
-
1No man. Read my question. `convertView.setBackgroundColor(android.R.color.transparent);` was not working. Read @antonyt answer. It worked. – Rajkiran Apr 03 '12 at 07:27
25
android.R.color.transparent
is a resource id (referring to a transparent color definition) - View.setBackgroundColor(int)
expects an actual int color.
Use View.setBackgroundResource(int) instead, which will load the actual color from resources.

antonyt
- 21,863
- 9
- 71
- 70
-
1worked, but why it's not working the obvious way is still a mystery. – halxinate Apr 08 '13 at 19:16
5
convertView.setBackgroundColor(Color.argb(0, 0, 0, 0));
OR
convertView.setBackgroundColor(Color.parseColor("#00000000"));

Vinothkumar Arputharaj
- 4,567
- 4
- 29
- 36
4
Use this from now in your xml's files when you want transparency in your views:
android:background="@null"
You are going to get a better performance.

danigonlinea
- 1,113
- 1
- 14
- 20