View Click to modify the background.
Change background when pressing, resume background when lifting, rely on state_pressed.
After successful landing, you are forbidden to click and change backgrounds, depending on state_enabled.
<?xml version= "1.0" encoding= "Utf-8"?><selector xmlns:android="Http://schemas.android.com/apk/res/android"> <item android:drawable="@android: Color/transparent"android:state_pressed ="true"/> <item android:drawable="@android: Color/transparent"android:state_enabled ="false"/> <item android:drawable="@color/white"/></selector>
System default Click Flicker Effect, version 5.0 and above support.
android:background="?android:attr/selectableItemBackground"
Code
<selector xmlns:android="Http://schemas.android.com/apk/res/android" Android:exitfadeduration="@android: Integer/config_mediumanimtime"> <item android:drawable="@color/transparent"android:state_window_focused ="false"/> <!--Even though these, the same resource, with the States so the drawable would invalidate itself when Coming out of pressed state. - <item android:drawable="@drawable/list_selector_background_disabled" android:state_enabled="false"android:state_focused="true"Android:state_ Pressed="true"/> <item android:drawable="@drawable/list_selector_background_disabled" android:state_enabled="false"android:state_focused="true"/> <item android:drawable="@drawable/list_selector_background_transition" android:state_focused="true"android:state_pressed="true"/> <item android:drawable="@drawable/list_selector_background_transition" android:state_focused="false"android:state_pressed="true"/> <item android:drawable="@drawable/list_selector_background_focused" android:state_focused="true"/> <item android:drawable="@color/transparent"/></selector>
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Android-View Click Effect