ExpandableListView - How to set divider only between parent elements

Plamen Nikolov picture Plamen Nikolov · Jul 14, 2011 · Viewed 38.4k times · Source

I want to put divider only between parent elements. When i set

android:divider="@drawable/divider"
android creates divider between parent elements, but creates divider between child elements too. When i add
android:childDivider="@color/transparent"
android removes the divider between child elements, but the free space between them remains. Why? I have tried to
android:dividerHeight="0dp"
but nothing happened.

At all i want to set divider between parent elements, but i do not want any divider or empty space between child elements.

any ideas how to do that??

Answer

Amala Ray picture Amala Ray · Nov 28, 2013

In order to remove dividers just from the child views and not between the parents in the expandable list:

add android:childDivider="#00000000" in the ExapandableListView attributes in XML:

<ExpandableListView
    android:id="@+id/elv"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:childDivider="#00000000" />

Refer this page for more information