Style and theme selector of Android learning notes, android learning notes
(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: paddingBottom = "@ dimen/activity_vertical_margin" android: paddingLeft = "@ dimen/plugin" android: paddingRight = "@ dimen/plugin" android: paddingTop = "@ dimen/plugin" tools: context = ". mainActivity "> <Button android: id =" @ + id/button1 "android: layout_width =" wrap_content "android: layout_height =" wrap_content "android: layout_alignParentBottom =" true "android: layout_alignParentLeft = "true" android: layout_marginBottom = "189dp" android: layout_marginLeft = "55dp" android: textColor = "@ color/button_selector" android: text = "test color list status"/> </RelativeLayout>
Use android: textColor = "@ color/button_selector" in the button"
(2) create a color folder under the res directory.
The content of the button-selector file is 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>
If other files are not modified, the default setting is OK.