android.R.color.transparent not fully transparent
Solution 1
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.
Solution 2
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
Solution 3
convertView.setBackgroundColor(Color.argb(0, 0, 0, 0));
OR
convertView.setBackgroundColor(Color.parseColor("#00000000"));
Solution 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.
Solution 5
Try:
convertView.setBackgroundColor(Color.argb(0, 0, 0, 0));
Comments
-
Rajkiran almost 2 years
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? -
Rajkiran about 12 yearsNo man. Read my question.
convertView.setBackgroundColor(android.R.color.transparent);
was not working. Read @antonyt answer. It worked. -
halxinate about 11 yearsworked, but why it's not working the obvious way is still a mystery.