android点击Button后,buttton的背景和颜色改变
android:background="@drawable/et_bg"
android:textColor="@drawable/login_btn_textcolor"
/>
背景代码:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_focused="true" android:drawable="@drawable/et_bg_press" /> <!-- focused -->
<item android:state_pressed="true" android:drawable="@drawable/et_bg_press" /> <!-- pressed -->
<item android:state_selected="true" android:drawable="@drawable/et_bg_press" /> <!-- pressed -->
<item android:drawable="@drawable/tv_bg" /> <!-- default --> //没有pressed时button的背景
</selector>
颜色代码
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_focused="true" android:color="@color/white" /> <!-- focused -->
<item android:state_pressed="true" android:color="@color/white" /> <!-- pressed -->
<item android:state_selected="true" android:color="@color/white" /> <!-- pressed -->
<item android:color="@color/title" /> <!-- default --> //没有pressed时button的颜色
</selector>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。