Android小知識——按鈕點擊的變化

以下是寫在Drawable裏面的btn_pre.xml文件

<?xml version="1.0" encoding="utf-8"?>

<selector xmlns:android="http://schemas.android.com/apk/res/android" >

    <item android:state_enabled="true" android:state_pressed="true" android:drawable="@drawable/pre2"/>

    <item android:drawable="@drawable/pre1"/>

</selector>

以下是調用的方法

<Button

                    android:id="@+id/pre"

                    android:layout_width="wrap_content"

                    android:layout_height="wrap_content"

                    android:layout_alignParentBottom="true"

                    android:layout_marginBottom="20dp"

                    android:layout_marginLeft="20dp"

                    android:background="@drawable/btn_pre" />


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