step1: 在res下面新建drawable folder,

step2:新增btn_change.xml

<?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/ic_launcher2"></item>
    <item android:state_enabled="false" android:drawable="@drawable/ic_launcher3"></item> 
    <item android:drawable="@drawable/ic_launcher1"></item>    
</selector>

step3:在相应的drawable-h,l,mdpi下面添加ic_launcher1.png,ic_launcher2.png,ic_launcher3.png

step4:在main.xml中,添加button的background引用

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

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

</LinearLayout>

 

posted on 2012-06-20 16:53  snowdrop  阅读(190)  评论(0编辑  收藏  举报