2013-10-03 351 views

回答

6

創建一個ImageView的(使用透明的PNG爲你的src圖像):

RES /佈局/ yourlayout.xml

<ImageView 
    android:layout_width=:"wrap_content" 
    android:layout_height=:"wrap_content" 
    android:background="@drawable/colorstates" 
    android:src="@drawable/image" /> 

RES /繪製/ colorstates.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item 
     android:drawable="@drawable/regular" 
     android:state_checked="true" 
     android:state_pressed="true" /> 
    <item 
     android:drawable="@drawable/pressed" 
     android:state_pressed="true" /> 
    <item 
     android:drawable="@drawable/pressed" 
     android:state_checked="true" /> 
    <item 
     android:drawable="@drawable/regular" /> 
</selector> 
0

是圖像需要透明背景,否則會覆蓋背景色。對圖像使用顏色background屬性和src。還請查看doc。對於按下狀態,請使用google!