将美工设计好的2张不同底色按钮背景图片png,拷贝到drawable里面
开始创建drawable下按钮切样式文件,如图:
保存,
编写按钮点击样式xml
Avtivity页下
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
tools:context="cn.cgrs.btndemo.MainActivity">
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/btnbg"
/>
注意:
android:background="@drawable/btnbg" //指向的是drawable的按钮样式文件
到此完成按钮点击切换不同效果。