Is it possible to change the left selected button in Selector xml?

I have a left frame assigned to a button, as well as a background feature. I want to set the selector so that when the user presses / focuses / disables the button, its appearance changes. The image I use for left-handed painting is red "x".

I would like this to be replaced by a gray β€œX” when the button is pressed or disabled. Is this possible with a selector?

Here is what I tried (which works for border / background image, but not for left-drawing (obviously).

<?xml version="1.0" encoding="utf-8" ?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_enabled="false" android:drawable="@drawable/GrayBorder" android:drawableLeft="@drawable/GrayRemove"/> <item android:state_pressed="true" android:state_enabled="true" android:drawable="@drawable/GrayBorder" android:drawableLeft="@drawable/GrayRemove" /> <item android:state_focused="true" android:state_enabled="true" android:drawable="@drawable/GrayBorder" android:drawableLeft="@drawable/GrayRemove" /> <item android:state_enabled="true" android:drawable="@drawable/BlackBorder" android:drawableLeft="@drawable/Remove"/> </selector> 
+8
android android-layout
source share
1 answer

Create a separate selector and try setting it as drawableLeft to Button .

+14
source share

All Articles