add below code to your parent layout
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground"
if you want custom ripple effect add this ripple_custom.xml in your drawable-v21
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/colorHighlight">
<item
android:id="@android:id/mask"
android:drawable="@color/windowBackground" />
</ripple>
to support older version add ripple_custom.xml in drawable
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<solid android:color="@color/colorHighlight" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="@android:color/transparent" />
</shape>
</item>
</selector>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…