以下是之前再作比賽隨手找到的資料,第一個是讓按鈕的背景可以透明化。
http://www.ideaex.net/html/Article/2011/08/09/397.html
Button或者ImageButton的背景設定為透明或者半透明
半透明<Button android:background="#e0000000" ... />
透明<Button android:background="#00000000" ... />
顏色和不透明度 (alpha) 值以十六進制表示法表示。任何一種顏色的範圍值都是 0 到 255(00 到 ff)。
對於 alpha,00 表示完全透明,ff 表示完全不透明。
表達式順序是“aabbggrr”,其中“aa=alpha”(00 到 ff);“bb=blue”(00 到 ff);“gg=green”(00 到 ff);“rr=red”(00 到 ff)。
例如,不透明度为 50% 的藍色:7fff0000。
http://code.google.com/p/androidbmi/wiki/ImageButton
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/button_pressed" />
<item android:state_focused="true"
android:drawable="@drawable/button_focused" />
<item android:drawable="@drawable/button_normal" />
</selector>
http://hi.baidu.com/pengwenfu/blog/item/a8acaaa5c4ce5bfb9152ee86.html
1。在res/drawable目錄下建一个mybutton.xml文件,我嘗試過好像無法直接新增,因此再res或者其他地方新增xml檔案,再拉到drawable下就可以了
再者檔名很重要,因為在接下宣告的imagebutton會提到。
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false"
android:drawable="@color/transparent" />
<item android:state_focused="true" android:state_enabled="false"
android:state_pressed="true"
android:drawable="@drawable/selector_background_disabled" />
<item android:state_focused="true" android:state_enabled="false"
android:drawable="@drawable/lselector_background_disabled" />
<item android:state_focused="true" android:state_pressed="true"
android:drawable="@drawable/selector_background_transition" />
<item android:state_focused="false" android:state_pressed="true"
android:drawable="@drawable/selector_background_transition" />
<item android:state_focused="true"
android:drawable="@drawable/selector_background_focus" />
</selector>
2。在xml檔案 新增imagebutton
<ImageButton
android:id="@+id/ImageButton01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/mybutton">
</ImageButton>