1.values/styles.xml下添加如下代码
<style name="RedButton" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="colorButtonNormal">#ff0000</item><!--正常状态下的颜色 -->
<item name="colorControlHighlight">#22000000</item><!--覆盖色,按下的颜色 -->
</style>
2.布局文件中的Button添加如下代码
style="@style/Widget.AppCompat.Button"
android:theme="@style/RedButton"
3.Button布局
<Button
style="@style/Widget.AppCompat.Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="退出登录"
android:textColor="@color/white"
android:theme="@style/RedButton" />