I had to put this into an answer, even though I'm not sure about it, but that's what I think:
I'll start with Q2:
state_window_focused
corresponds to the default behaviour ("window" visible, but unfocused) and I think it's used just to point out the default (TRANSPARENT
).
About Q1:
DRAWABLE2
will be visualised in both cases and under the same conditions - focused and unpressed, because:
First case:
<item android:drawable="<DRAWABLE_2>" android:state_focused="true"/>
Second case:
`<item android:drawable="<DRAWABLE_2>" android:state_focused="true" android:state_pressed="false"/>`
We have the D2 while focused, but in your case also while unpressed.
DRAWABLE1
will be visible only while pressed in each and every case. The difference is that in the first case, the two additional states are given too android:state_focused="true/false"
, which doesn't make any sense, so the two lines in Case 1 can be shrunk to one (exactly the one you have):
<item android:drawable="<DRAWABLE_1>" android:state_pressed="true"/>
So, to sum things up:
Case 1 - you have :
<selector>
<item android:drawable="<TRANSPARENT>" android:state_window_focused="false"/>
<item android:drawable="<DRAWABLE_1>" android:state_focused="true" android:state_pressed="true"/>
<item android:drawable="<DRAWABLE_1>" android:state_focused="false" android:state_pressed="true"/>
<item android:drawable="<DRAWABLE_2>" android:state_focused="true"/>
</selector>
Which is equivalen to:
<selector>
<item android:drawable="<TRANSPARENT>" android:state_window_focused="false"/>
<item android:drawable="<DRAWABLE_1>" android:state_pressed="true"/>
<item android:drawable="<DRAWABLE_2>" android:state_focused="true"/>
</selector>
And your case (case 2), for comparison:
<selector>
<item android:drawable="<DRAWABLE_2>" android:state_pressed="false" android:state_focused="true"/>
<item android:drawable="<DRAWABLE_1>" android:state_pressed="true"/>
<item android:drawable="<TRANSPARENT>" />
</selector>
The only difference I can see so far, is that in the first case, the DRAWABLE2
will be shown only when focused (no matter if pressed or not), but in your case it has to be also unpressed and that's the only condition which is different.