Search code examples
androidtransparentexpandablelistviewdivider

Hide divider without hiding childDivider on ExpandableListView


I can't find a way to hide dividers on an ExpandableListView without hiding the child dividers too.

Here is my code.

<ExpandableListView 
            android:id="@+id/activities_list"
            android:background="@android:color/transparent"
            android:fadingEdge="none"           
            android:groupIndicator="@android:color/transparent"
            android:divider="@android:color/transparent"
            android:childDivider="@drawable/list_divider"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />

With this code, I get no dividers on groups but no child dividers neither. If I set android:divider to "@drawable/list_divider" I get both group and child dividers.

Thanks in advance!


Solution

  • The only solution I found is to put the child divider directly into the children XML, this way:

    <TextView
        android:id="@+id/name"
        android:layout_centerVertical="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    
    <ImageView android:id="@+id/divider"        
        android:layout_alignParentBottom="true"
        android:layout_width="fill_parent"
        android:layout_height="1dp"
        android:background="@drawable/list_divider" />        
    

    which is very very ugly but works.

    But still, there should be a way to do that properly.