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?
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.
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”).
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With