简体   繁体   中英

Setting alpha transparency at a listView android

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.

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.

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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM