Android-View Click Effect

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.