Как выбрать в XML, для свойства android:drawable
, одного из чертежей, определенных в XML-уровне на уровне?
Я определяю чертежи в самом XML-уровне, чтобы избежать определения множества небольших XML-файлов.Android Выбор выделенного из уровня списка в XML
<?xml version="1.0" encoding="utf-8"?>
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:maxLevel="0">
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="@color/empty"
android:endColor="@android:color/white"
android:angle="90" />
</shape>
</item>
<item android:maxLevel="1">
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:startColor="@color/low"
android:endColor="@android:color/white"
android:angle="90" />
</shape>
</item>
<item android:maxLevel="2">
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="@color/middle"
android:endColor="@android:color/white"
android:angle="90" />
</shape>
</item>
<item android:maxLevel="3">
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="@color/high"
android:endColor="@android:color/white"
android:angle="90" />
</shape>
</item>
<item android:maxLevel="4">
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="@color/full"
android:endColor="@android:color/white"
android:angle="90" />
</shape>
</item>
</level-list>