Android中Button 有focused, selected, pressed 等不同状态,通过配置一个XML格式的 drawable "selector" 即可实现”在不同状态下显示不同背景图片“的功能。
1. 在res/drawable目录下添加一个xml文件,用来描述Button在不同状态下对应的不同图片。我这里给该xml文件命名为btn_background.xml
2. 在res/layout目录下,对应的layout xml文件中,将Button的android:background属性设置为btn_background即可。
3.运行结果
默认状态(unselected)
点击状态(pressed)
参考资料:
Google Android开发文档:ImageButton
http://developer.android.com/reference/android/widget/ImageButton.html
延伸阅读
- 2011-1-11-- 摩托罗拉分拆,摩托罗拉分拆后再"融合 Android差异化战略
- 2011-1-10-- android,未来但不是现在,Android将是最后的赢家
- 2011-1-7-- android,Android产业链部分企业链积极行动封堵SP吸费
- 2010-12-18-- android,NEC双屏Android平板机下月CES亮相
- 2011-1-6-- 亚马逊开放平台,亚马逊Android应用商店面向开发人员开放
- 2011-1-5-- android,亚马逊向开发人员推出Android应用商店
- 2011-1-6-- android,机构称宏达电去年Android市场份额跌至32%
- 2011-1-5-- android,亚马逊面向开发人员推出Android应用商店
- 2011-1-5-- android,亚马逊面向开发人员推出Android应用商店
- 2010-12-21-- android,警惕你手机中的应用偷偷扫描你的隐私——Android手机安全篇
最新评论