Statement: Demo is not written by me, I just summed up here
Project Source: Rippledemo.zip
----------------------------------------------------
Master
1. Ripple without boundaries (Ripple with no Mask)
2. Ripple with color as mask (Ripple with color mask), but the color does not have any egg
3. Ripple with image as mask (Ripple with picture mask)
4. Ripple with a set shape as mask (Ripple with shape mask)
5. Paired with Selector as Ripple (Ripple with Selector)
----------------------------------------------------
1. Ripple without boundaries (Ripple with no Mask)
<ripple> tags
Ripple tag, which corresponds to a rippledrawable, when it is set to the background property of a control, the water wave effect is displayed when the control is pressed
Ripple_red.xml
<? XML version= "1.0" encoding= "Utf-8" ?> < xmlns:android= "http://schemas.android.com/apk/res/android" Android:color = "#FF0000"> </ripple>
Use
< TextView Android:layout_width = "Match_parent" android:layout_height= "Match_parent" android:background= "@drawable/ Ripple_red " android:clickable=" true " android:gravity=" Center " android:text=" Ripple with No Mask "/>
Effect:
2. Ripple with color as mask (Ripple with color mask), however, the color is not an egg and is useful for qualifying boundaries.
If you add an item to an ripple tag, its ID is the @android:id/mask,drawable property is a reference color (color), The water wave effect is limited to the drawable corresponding to the rippledrawable itself within the rectangular region.
Ripple_red_with_white_mask.xml
<?XML version= "1.0" encoding= "Utf-8"?><Ripplexmlns:android= "Http://schemas.android.com/apk/res/android"Android:color= "#FF0000" > <ItemAndroid:id= "@android: Id/mask"android:drawable= "@android: Color/white" /> </Ripple>
Effect
3. Ripple with image as mask (Ripple with picture mask)
If you add an item to an ripple tag whose ID is the @android:id/mask,drawable property as the referenced picture (png,jpg), the water wave effect is limited to the area within the region corresponding to the non-transparent portion of the picture drawable.
Ripple_red_with_pic_mask
<?XML version= "1.0" encoding= "Utf-8"?><Ripplexmlns:android= "Http://schemas.android.com/apk/res/android"Android:color= "#FF0000" > <ItemAndroid:id= "@android: Id/mask"android:drawable= "@drawable/icon_folder_r" /> </Ripple>
Effect:
4. Ripple with a set shape as mask (Ripple with shape mask)
If you add an item to an ripple tag whose ID is the @android:id/mask,drawable property is a referenced shape (shape), the water wave effect is limited to the area within the shape.
Define Shape:shape.xml First
<?XML version= "1.0" encoding= "Utf-8"?><Shapexmlns:android= "Http://schemas.android.com/apk/res/android"Android:shape= "Rectangle"> <SolidAndroid:color= "#ff9d77"/> <CornersAndroid:bottomrightradius= "100DP"/></Shape>
In the definition Ripple:ripple_red_with_shape_mask
<?XML version= "1.0" encoding= "Utf-8"?><Ripplexmlns:android= "Http://schemas.android.com/apk/res/android"Android:color= "#FF0000" > <ItemAndroid:id= "@android: Id/mask"android:drawable= "@drawable/shape"/></Ripple>
Effect:
5. Paired with Selector as Ripple (Ripple with Selector)
If you add an item to an ripple tag and write a <selector> tag inside the item, the rippledrawable is pressed with a water-wave effect and selector the specified layer.
Ripple_red_with_selector
<?XML version= "1.0" encoding= "Utf-8"?><Ripplexmlns:android= "Http://schemas.android.com/apk/res/android"Android:color= "#FF0000" > <Item> <selector> <Itemandroid:drawable= "@drawable/icon_folder_i"android:state_pressed= "true"> </Item> <Itemandroid:drawable= "@drawable/icon_folder_r"android:state_pressed= "false"> </Item> </selector> </Item></Ripple>
Effect
Use of Android L Ripple