2010-02-03 37 views
3

我正在嘗試使ImageButton處於按下,聚焦和正常狀態。 我讀過ImageButton的介紹hereImageButton選擇器不起作用?

我已經將選擇器XML文件保存在/ res/drawable /中。還要設置android:src="@drawable/my_selector"

my_selector.xml文件:

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item android:drawable="@drawable/btn_unfocus" /> <!-- default --> 
    <item android:state_pressed="true" 
      android:drawable="@drawable/btn_onpress" /> <!-- pressed --> 
    <item android:state_focused="true" 
      android:drawable="@drawable/btn_onfocus" /> <!-- focused --> 
</selector> 

我覺得我已經做了正確的ImageButton。但它不適合我。

這裏有什麼問題?

請指教。

+0

kenu.heo有很好的答案,你可以接受它 – AndrewS 2014-01-08 17:47:38

回答

5

應該訂購商品標籤。 所以第一次按下,聚焦,最後是默認項

參考Here

0

你犯錯。 試試這個。

android:background="@drawable/your_selector_name"