How to make the ListView transparent in android?
The background android screen image should be visible.
How to make the ListView transparent in android?
The background android screen image should be visible.
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.
android:background="@android:color/transparent" android:cacheColorHint="@android:color/transparent"
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"
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"
Add this to make list items stay transparent when pressed:
android:listSelector="@android:color/transparent"
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/
You can use these
android:background="@android:color/transparent"
android:listSelector="@android:color/transparent"
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.
Check this blog.
[http://aboutyusata.blogspot.in/2013/10/how-to-make-listview-with-transparent.html][1]
or
android:background="@android:color/transparent"
© 2022 - 2024 — McMap. All rights reserved.