Zach Zach - 1 year ago 116
Android Question

How to create ripple effect in simple layout

How can I have a ripple effect in a simple linear/relative layout when touching the layout?

I've tried setting the background of a layout to something like:

<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android=""
android:color="?android:colorControlHighlight" >

<item android:drawable="@android:color/white"/>


However I'm only seeing a plain white background and no ripple effect when touching the layout. What am I doing wrong?


For reference, here is my layout xml file:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android=""

Answer Source

It turns out this is working as intended. The standard Material theme colorControlHighlight value is #40ffffff. So on a white background, this will not show up. Changing the highlight color to something else works, and/or changing the background color of the object.

Thanks all (especially Alanv for pointing me in the right direction).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download