hanafey (18) [Avatar] Offline
#1
On page 160 the book says:

<style name="MMListView" parent=”@android:style/Widget.ListView”>
<item name="android:background">#A000</item>
<item name="android:fastScrollEnabled">true</item>
<item name="android:footerDividersEnabled">false</item>
</style>

We're already using a drawable here, can you see it? Well, to be fair, it's not really
jumping out. It's the color we used as the list's background. Android will turn color values
which are passed to an attribute that expects a drawable (which are typically graphics like
images) into a ColorDrawable internally. We could have passed an entirely different kind


But if you try to set "android:windowBackground" to a color value it is an error. It seems perfectly reasonable to want to set this to a simple color, but for some reason "android:background" and "android:windowBackground" are not treated the same way.

In this case it would be better if the platform behaved exactly how the book suggests it should!
matthias.kaeppler (8) [Avatar] Offline
#2
Re: A color value cannot always be passed when a Drawable is expected
Good point. I will update that paragraph to mention that.