Setting alpha transparency at a listView android

9.8k views Asked by At

Hi i would like to set some transparency to my listview , i've alredy see some examples of that , but all of than were a 100% transparent .

as this topic : How to make the ListView transparent in android?

As Jacky mentioned, setting attributes for list view will do the job.

android:background="#00000000"
android:cacheColorHint="#00000000"

But in my case i just want to make it half transparent , some sort of alpha 50 and stuff. My goal here is that the user could see the background of the UI through listview but also see the background of my listView with a bit of transparecy.

How can i achieve that ?

Thanks.

3

There are 3 answers

3
Kiril Kirilov On BEST ANSWER

If I recall correctly, first two digits from #00000000 are for alpha channel.

Something like #80XXXXXX will be 50% transparency.

You can refer Color State List for further explanation.

0
guido On

Colors are expressed in ARGB color space, so #336699CC is:

0x33 transparency 0x66 red component 0x99 green component 0xcc blue component

0
Sunil On

You can programitically set the transparency level of the UI element.
yourUIElement.setAlpha(0.5) makes 50% transparent.
The setAlpha method takes the value from 0 to 1
0 : Completely Transparent
1 : Completely Opaque.