Selector---Selector
Selector can often be seen in the use of the app
Such as: A key appears white or other color, may be a picture
Press down and show other colors or another picture
Use shape together here
Normal state
<?xml version= "1.0" encoding= "Utf-8"?><!--Rectangle rectangular Oval oval line one wire ring ring--><shape Android:shape= "Rectangle" xmlns:android= "http://schemas.android.com/apk/res/android" > <!-- 4 corners of rounded corners-- <corners android:radius= "8DP"/> <!--inner margin- <padding android:bottom= "5DP" android:left= "3DP" android:right= "3DP" android:top= "5DP"/> <!--fill Color- < Solid android:color= "#09A3DC"/> <!--border Color- <stroke android:color= "#88000000" Android : width= "1DP"/> </shape>
Press the status
<?xml version= "1.0" encoding= "Utf-8"?><!--Rectangle rectangular Oval oval line one wire ring ring--><shape Android:shape= "Rectangle" xmlns:android= "http://schemas.android.com/apk/res/android" > <!-- 4 corners of rounded corners-- <corners android:radius= "8DP"/> <!--inner margin- <padding android:bottom= "5DP" android:left= "3DP" android:right= "3DP" android:top= "5DP"/> <!--fill Color- < Solid android:color= "#0066A0"/> <!--border Color- <stroke android:color= "#88000000" Android : width= "1DP"/> </shape>
Selector
<?xml version= "1.0" encoding= "Utf-8"? ><selector xmlns:android= "http://schemas.android.com/apk/res/ Android > <!--Press to display this shape android:state_pressed= "True" here can have a variety of state options,-- <item android:drawable= "@drawable/shap_btn_press" android:state_pressed= "true"/> <!--usually show this shape--> <item android:drawable= "@drawable/shap_btn_normal"/></selector>
References in layouts
<button android:layout_margin= "10DP" android:layout_width= "match_parent" android:layout_height = "Wrap_content" android:textcolor= "#ffffff" android:background= "@drawable/selector_main_btn" android:text= "OK"/>
There are pictures to go to need to create a selector in drawable specify a different picture, in ImageView specify background use selector, and then specify the phase event to trigger,
Here is the Click event
<selector xmlns:android= "Http://schemas.android.com/apk/res/android" > <item android:state_pressed= " True "android:drawable=" @drawable/ic_menu_add_pressed "/> <item android:drawable=" @drawable/ic_menu_add _normal "/></selector>
Android--selector Simple to use