实现button的点击效果:
定义button的背景文件button_bg.xml,放在drawable文件夹下。
<?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/button_press"></item>
<item android:drawable="@drawable/button_normal"></item>
</selector>
设置button的背景:
android:background="@drawable/button_bg"
本文介绍如何通过定义XML选择器实现按钮的点击效果。首先创建button_bg.xml文件,利用状态选择器设置按下状态和默认状态的不同背景图片,然后将该文件设置为Button的背景。
964

被折叠的 条评论
为什么被折叠?



