(1) Layout file
<relativelayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http// Schemas.android.com/tools "android:layout_width=" match_parent "android:layout_height=" Match_parent "Android:paddi ngbottom= "@dimen/activity_vertical_margin" android:paddingleft= "@dimen/activity_horizontal_margin" Android: paddingright= "@dimen/activity_horizontal_margin" android:paddingtop= "@dimen/activity_vertical_margin" tools: Context= ". Mainactivity "> <button android:id=" @+id/button1 "android:layout_width=" Wrap_content "Androi d:layout_height= "Wrap_content" android:layout_alignparentbottom= "true" android:layout_alignparentleft= "true" Android:layout_marginbottom= "189DP" android:layout_marginleft= "55DP" android:textcolor= "@color/butto N_selector "android:text=" Test Color list status "/></relativelayout>
Need to use inside the button: android:textcolor= "@color/button_selector"
(2) You need to create a color folder in the Res directory
The contents of the Button-selector file are as follows:
<?xml version= "1.0" encoding= "Utf-8"? ><selector xmlns:android= "http://schemas.android.com/apk/res/ Android "> <item android:state_pressed=" true "android:color=" #ffff0000 "/> <item Android:state_ Focused= "true" android:color= "#ff0000ff"/> <item android:color= "#ff000000"/></selector>
Other files do not change, the default can be
The style and theme selector for Android learning notes