2010-03-13 47 views

回答

0

你需要編寫自己的類爲該。只是子類查看並監聽onClick事件。

0

嘗試使用選擇器作爲背景。

<Button 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/hello" 
     android:background="@drawable/my_button" 
    /> 

,然後作出my_button.xml在繪製文件夾。

<?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/focused" /> 
    <item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/focusedpressed" /> 
    <item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/pressed" /> 
    <item android:drawable="@drawable/defaultbutton" /> 
</selector> 

來源:http://www.anddev.org/tinytutcustom_button_backgrounds-better_imagebutton-t4298.html