Is there a way to combine the effects of StateListDrawable and LevelListDrawable?
I wrote this resource file, but when using nothing is displayed:
<?xml version="1.0" encoding="utf-8"?>
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<selector
android:constantSize="true"
android:variablePadding="false"
android:maxLevel="0"
>
<item android:state_pressed="true">
<layer-list>
<item android:drawable="@drawable/btu_color_standard" />
<item android:drawable="@drawable/btu_shade_pressed" />
</layer-list>
</item>
<item android:state_focused="true">
<layer-list>
<item android:drawable="@drawable/btu_color_standard" />
<item android:drawable="@drawable/btu_shade_selected" />
</layer-list>
</item>
<item>
<layer-list>
<item android:drawable="@drawable/btu_color_standard" />
<item android:drawable="@drawable/btu_shade_normal" />
</layer-list>
</item>
</selector>
<selector
android:constantSize="true"
android:variablePadding="false"
android:maxLevel="1"
>
<item android:state_pressed="true">
<layer-list>
<item android:drawable="@drawable/btu_color_standard" />
<item android:drawable="@drawable/btu_lighted" />
<item android:drawable="@drawable/btu_shade_pressed" />
</layer-list>
</item>
<item android:state_focused="true">
<layer-list>
<item android:drawable="@drawable/btu_color_standard" />
<item android:drawable="@drawable/btu_lighted" />
<item android:drawable="@drawable/btu_shade_selected" />
</layer-list>
</item>
<item>
<layer-list>
<item android:drawable="@drawable/btu_color_standard" />
<item android:drawable="@drawable/btu_lighted" />
<item android:drawable="@drawable/btu_shade_normal" />
</layer-list>
</item>
</selector>
</level-list>
Then i call
_btn.getBackground().setLevel(level); //level is either 0 or 1
to change the drawable level (_btn - btw button).
Why is this not working?
Thanks in advance.
source
share