一.res文件夹下新建一个文件夹drawable,这是无关分辨率的:
在下面建立一个xml文件:login_button_selector.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/clr_normal" android:state_pressed="false"/>
<item android:drawable="@drawable/clr_pressed" android:state_pressed="true"/>
</selector>
二.在value文件夹下的string.xml文件里添加:
<drawable name="clr_normal">#ff6501</drawable>
<drawable name="clr_pressed">#a44100</drawable>
三.给button添加background属性:
<Button
android:layout_marginTop="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/loginSubmit"
android:id="@+id/login"
android:textColor="@android:color/white"
android:background="@drawable/login_button_selector"
/>