The documentation of the XML resource specification of LayerList and LevelList drawables says that the item
element will only accept bitmap
as child element. On some answers concerning level lists, I see that people are adding shape
tags as children to the item
tags. I tried out the following and it seems to work nicely.
<?xml version="1.0" encoding="utf-8"?>
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:maxLevel="0">
<shape android:shape="rectangle">
<solid android:color="#ff0000" />
</shape>
</item>
<item android:maxLevel="1">
<shape android:shape="oval">
<solid android:color="#0000ff" />
</shape>
</item>
</level-list>
Here is my question. Is this documented anywhere, or should I avoid this kind of construct because it is not supported in all API versions, or is the documentation simply incomplete and the above is perfectly legal?
To clarify, I know that I can specify any sort of drawable by using separate resource files and referring to them using the android:drawable
attribute. The question refers to the inline specification of arbitrary drawables within the XML of the layer list or level list.
will work. – Larry Schiefer Jan 08 '14 at 20:30