Romain Guy wrote: > There's a way to do this. Simply set your background texture on the > list items, but use a selector for the background. For the state > android:state_selected="true", simply use @android:color/transparent > as the background. This way, when an item is selected, its texture > won't be shown, and you will be able to see the list selector.
Ah, I didn't know about state_selected (would you like a bug report on documentation for this?). Yes, that works fine. In fact, I've managed to simplify considerably and have put all the logic into the list item's background: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_selected="true"> <shape android:shape="rectangle"> <gradient android:startColor="#fff203" android:endColor="#ff6815" android:angle="270" /> </shape> </item> <item android:state_selected="false"> <shape android:shape="rectangle"> <gradient android:startColor="#b9b9b9" android:endColor="#868686" android:angle="270" /> </shape> </item> </selector> That way I don't need to fiddle with the ListView at all. Incidentally, he also wants custom dividers in the ListView. I have that working, but along the way I found out that it doesn't seem to want to honour the dividerHeight attribute. The only way of setting the height of the dividers is to point divider at a fixed-height drawable, like a PNG file. Is this a bug, or simply something I'm not doing right? -- ┌─── dg@cowlark.com ───── http://www.cowlark.com ───── │ │ "All power corrupts, but we need electricity." --- Diana Wynne Jones, │ _Archer's Goon_
signature.asc
Description: OpenPGP digital signature