android button 点击时改变颜色


1.通过图片进行切换

效果图 平时:           点击时:  

2.设置一个button

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/button_selectors"/>

3.在drawable下建立button_selectors.xml文件

4.在drawable中分别放两个图片clr_normal.png 和 clr_pressed.png两张图片(对应上图)

5.代码编写,输入如下代码。运行程序即可!

 

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM