我为我的按钮创建了 2 种不同的状态,并且为此购买创建了选择器:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/level1_calm" />
<item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/level1_on_click" />
<item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/level1_on_click" />
<item android:drawable="@drawable/level1_calm" />
</selector>
但是我怎样才能对所有按钮只使用一个选择器,或者它是被禁止的。
我的意思是我可以在这里使用一些变量,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/level`$Number_button`_calm" />
<item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/level`$Number_button`_on_click" />
<item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/level`$Number_button`_on_click" />
<item android:drawable="@drawable/level`$Number_button`_calm" />
</selector>