Nidhin Kumar
Nidhin Kumar

Reputation: 3579

How to add Ripple effect for list item in expandable listview in android

I am creating an application which consist of expandable listview i want to make a ripple effect for the list item in the expandable listview for which i have created a ripple drawable and added color in it and changed the android:background in the expandable listview to android:listselector but still the ripple effect is not working in the application.

Drawable:

<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/colorlightAccent">
<item android:drawable="@color/white"/>
</ripple>

Xml:

    <codingtown.coconut.libraries.expandablelistview.ExpandableHeightListView
                android:id="@+id/detaillist_daybook"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:listSelector="@drawable/list_item_drawable"
                android:dividerHeight="1dp"
                android:fastScrollEnabled="true"
                android:groupIndicator="@null"
                android:paddingTop="5dp"
                android:scrollingCache="false"
                android:smoothScrollbar="true">

            </codingtown.coconut.libraries.expandablelistview.ExpandableHeightListView>

Upvotes: 0

Views: 847

Answers (2)

faiyaz meghreji
faiyaz meghreji

Reputation: 271

Add this line to android:background="?selectableItemBackground" listview item layout

Upvotes: 3

amalBit
amalBit

Reputation: 12181

You have missed android:id="@android:id/mask" inside ur ripple.

<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/colorlightAccent">
<item  android:id="@android:id/mask"android:drawable="@color/white"/>
</ripple>

First try a visible color for your ripple. If you background color is also white, you wont be able to see.

Also dont forget to add a backward compatible drawable if your app is supported on android versions less that 5.0.

Upvotes: 0

Related Questions