Android Water Ripple Effect implementation

Source: Internet
Author: User

1. Under the drawable file, create a new seletor, as the background of the button, here I use the shape of two rounded corners

<?XML version= "1.0" encoding= "Utf-8"?><selectorxmlns:android= "Http://schemas.android.com/apk/res/android"><Itemandroid:drawable= "@drawable/shape_btn_cycle_normal"/>    <Itemandroid:state_pressed= "true"android:drawable= "@drawable/shape_btn_cycle_press"/></selector>

Shape_btn_cycle_normal

<?XML version= "1.0" encoding= "Utf-8"?><Shapexmlns:android= "Http://schemas.android.com/apk/res/android"Android:shape= "Rectangle">    <CornersAndroid:bottomleftradius= "20DP"Android:bottomrightradius= "20DP"Android:topleftradius= "20DP"Android:toprightradius= "20DP"/>    <SolidAndroid:color= "@color/colorwhite"/></Shape>

Shape_btn_cycle_press

<?XML version= "1.0" encoding= "Utf-8"?><Shapexmlns:android= "Http://schemas.android.com/apk/res/android"Android:shape= "Rectangle">    <CornersAndroid:bottomleftradius= "20DP"Android:bottomrightradius= "20DP"Android:topleftradius= "20DP"Android:toprightradius= "20DP"/>    <SolidAndroid:color= "@color/colorgray"/></Shape>

2. Under the DRAWABLE-V21, the new ripple with selector name, as above, my selector is SELECTOR_BTN_CYCLE_BG, here drawable-v21 under the new Selector_btn_cycle_ Bg.xml

 <?  xml version= "1.0" encoding= "Utf-8"  ?>  <  ripple  xmlns:android  = "Http://schemas.android.com/apk/res/android"   Android:color  = "@color/colorgray"  >  //color of the selected water ripple  <  item  android:drawable  = "@drawable/shape_btn_cycle_normal"  />  //unselected background State  </ ripple  >  

Android Water Ripple Effect implementation

Related Article

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.