Reputation: 845
How to make the ListView transparent in android?
The background android screen image should be visible.
Upvotes: 64
Views: 91507
Reputation: 1905
android:background="@android:color/transparent" android:cacheColorHint="@android:color/transparent"
Upvotes: 60
Reputation: 271
Check this blog.
[http://aboutyusata.blogspot.in/2013/10/how-to-make-listview-with-transparent.html][1]
or
android:background="@android:color/transparent"
Upvotes: 0
Reputation: 3241
You can use these
android:background="@android:color/transparent"
android:listSelector="@android:color/transparent"
Upvotes: 3
Reputation: 2080
If you want to use partial transparency, this would help you while setting your color codes.
2 hex characters can be appended to any hex color code. The first 2 characters in an 8-digit hex color code represents its opacity in Android.
The 2 hex characters can range from 00 to FF. For example-
This way you can change any color to any level of transparency.
Source- http://zaman91.wordpress.com/2010/03/22/android-how-to-create-transparent-or-opeque-background/
Upvotes: 3
Reputation: 41
Add this to make list items stay transparent when pressed:
android:listSelector="@android:color/transparent"
Upvotes: 4
Reputation: 8054
As Jacky mentioned, setting attributes for list view will do the job.
android:background="#00000000"
android:cacheColorHint="#00000000"
In Android manifest file add following attribute to activity.
android:theme="@android:style/Theme.Dialog"
Upvotes: 13
Reputation: 43544
You should use the more verbose
android:background="@android:color/transparent"
android:cacheColorHint="@android:color/transparent"
Updated with Jacky's response. I originally merely meant to add to his answer, since he was using a plain hex color in the sample.
Upvotes: 123
Reputation: 2121
The answers above will work, but there is a chance that when you'll scroll the listView, it will darken, like in this case: android-listview problem with transparent cells
To solve the issue, you can use the cacheColorHint as mentioned above, but if you add the ListView dynamically (from code, not xml), then this will not work. You are forced to declare the ListView in XML, dunno if this is a bug or something else.
Upvotes: 1
Reputation: 427
This article helps explain the nuances of ListView in conjunction with a custom background - http://developer.android.com/resources/articles/listview-backgrounds.html
tl;dr - put this in the offending ListView's xml somewhere:
android:cacheColorHint="#00000000"
Upvotes: 4