Android 5.0--Ripple effect

Source: Internet
Author: User

Ripple water ripple effect, that is, ripple effect.

There are two types of ripple effects:

1, Ripple has boundary: ripple Ripple effect is only displayed inside the control

Android:background= "? Android:attr/selectableitembackground"

2, ripple out of bounds: ripple ripple effect is not restricted inside the control

Android:background= "? android:attr/selectableitembackgroundborderless"

By adding the code to the layout file, you can control the display area of the ripple effect more flexibly.

To set the color of the ripple:

Android:colorcontrolhighlight: Set Ripple Color
Set the selected color for a control such as a checkbox:
Android:coloraccent: Set the selected color of a control such as a checkbox

res/drawable/Ripple_round.xml

<?XML version= "1.0" encoding= "Utf-8"?><Ripplexmlns:android= "Http://schemas.android.com/apk/res/android"Android:color= "? Android:colorprimary">    <Item>        <ShapeAndroid:shape= "Oval">            <SolidAndroid:color= "? Android:colorprimary" />        </Shape>    </Item></Ripple>

res/drawable/Oval.xml

<?XML version= "1.0" encoding= "Utf-8"?><Ripplexmlns:android= "Http://schemas.android.com/apk/res/android"Android:color= "? Android:colorcontrolhighlight">    <Item>        <ShapeAndroid:shape= "Oval">            <SolidAndroid:color= "#738ffe" />        </Shape>    </Item></Ripple>

Used in Layout files:

< Button         Android:id = "@+id/fab_button"         android:layout_width= "56DP"        android:transitionname= "Fab"         Android:layout_height = "56DP"         android:background= "@drawable/ripple_round"        android:elevation  = "5DP"/>

Android 5.0--Ripple 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.