Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android.R.color.transparent not fully transparent

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?

like image 343
Rajkiran Avatar asked Apr 03 '12 07:04

Rajkiran


People also ask

What is color transparent in Android?

What is color transparent in Android? TRANSPARENT (which represents the same thing as @android:color/transparent ) is equal to 0 . The hex representation of 0 is #00000000 , which means that Color. TRANSPARENT is essentially a completely transparent Color.

How do I make RGB transparent?

Make transparent colors in RThe rgb() command is the key: you define a new color using numerical values (0–255) for red, green and blue. In addition, you set an alpha value (also 0–255), which sets the transparency (0 being fully transparent and 255 being “solid”).

Is there a color code for transparent?

You can actually apply a hex code color that is transparent. The hex code for transparent white (not that the color matters when it is fully transparent) is two zeros followed by white's hex code of FFFFFF or 00FFFFFF.


2 Answers

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.

like image 113
antonyt Avatar answered Nov 01 '22 22:11

antonyt


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

like image 23
Zumbarlal Saindane Avatar answered Nov 01 '22 21:11

Zumbarlal Saindane