Button控件应用

一、自定义背景的Button

 

android:background="@drawable/btn"

 res/drawable/btn.xml

 

<?xml version="1.0" encoding="UTF-8"?>
<selector
	xmlns:android="http://schemas.android.com/apk/res/android">
	<item
		android:state_pressed="false"
		android:state_focused="true"
		android:drawable="@drawable/img1" />
	<item
		android:state_pressed="true"
		android:state_focused="true"
		android:drawable="@drawable/img2" />
	<item
		android:state_pressed="true"
		android:state_focused="false"
		android:drawable="@drawable/img3" />
	<item
		android:drawable="@drawable/img4" />
</selector>

  效果:只显示未按下的img4和按下时的img3


Button控件应用


Button控件应用

 

你可能感兴趣的:(button)