Android自定義按鈕

1、畫9.png圖片

2、/drawable文件下寫.xml文件設置按鈕的狀態:

<?xml version="1.0" encoding="utf-8"?>
<selector
  xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_pressed="false" android:drawable="@drawable/button" />
  <item android:state_pressed="true" android:drawable="@drawable/b_pressed" />
  <item android:state_focused="true" android:drawable="@drawable/b_pressed"/> 
</selector>

3、用TextView當按鈕,設置background屬性,設置點擊監聽事件


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章