The Click Effect of the button is undoubtedly very simple, so that I am lazy to when the UI tells me that the color of the button font when clicked to change with the background when I did not hesitate to tell him to cut two pictures come over, then think really is not very reliable, Then I learned how to add the font color change effect of the button click.
1. First you want to add a few of the color values you need under your color file, note that the difference is not a generic color tag, but a drawable tag, like this:
- <drawable name="color_red">#fffa3d39</drawable>
- <drawable name="Color_green">#ff00adba</drawable>
- <drawable name="Color_gray">#fff4f4f8</drawable>
2. Then you want to define a drawable file, just like the normal selector file, the only difference is to turn the drawable field into color and introduce the color you just defined
- <? XML version= "1.0" encoding="Utf-8"?>
- <selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_focused="false" android:state_enabled="true" Android:state_ pressed="false"
- android:color="@drawable/color_red" />
- <item android:state_enabled="false" android:color="@drawable/color_gray" />
- <item android:state_pressed="true" android:color="@drawable/color_green" />
- <item android:state_focused="true" android:color="@drawable/color_red" />
- </Selector>
3. Finally set the second step of the drawable file to the TextColor option in your layout file.
Done!
The color effect of the font after button click in Android