Skip to content

Instantly share code, notes, and snippets.

@ipereziriarte
Last active August 29, 2015 14:17
Show Gist options
  • Save ipereziriarte/c88a268a70cf9d1dc96d to your computer and use it in GitHub Desktop.
Save ipereziriarte/c88a268a70cf9d1dc96d to your computer and use it in GitHub Desktop.
Add a Ripple background to a list
<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:listSelector="@drawable/my_ripple"
android:drawSelectorOnTop="true"/>
<!-- drawSelectorOnTop is actually very important: without it the ripple will be drawn under row view -->
<!-- Alternative way -->
<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:listSelector="?attr/selectableItemBackground" />
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/red">
<item
android:id="@android:id/mask"
android:drawable="@color/red_bg"/>
</ripple>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment