Android: Hide child dividers in ExpandableListView

Viewed 38757

I need to completely remove dividers from ExpandableListView. As for parent items it's a setDividerHeight method where I can pass a zero value. But there's no similar method for child divider. Is there any way to hide it?

7 Answers

to hide the child divider set it color to transparent #00000000

define transparent in your color.xml file

<color name="transparent">#00000000</color>

and then set the child divider

listView.setChildDivider(getResources().getDrawable(R.color.transparent))

or in the layout xml file

<ExpandableListView 
android:layout_width="fill_parent"
android:layout_height="fill_parent" 
android:childDivider="#00000000"/>

instead of writing lengthy code use property ExpandableListView. It will work :-

android:childDivider="@android:color/transparent" 

android:divider="@color/tranceParent"

 <ExpandableListView
        android:id="@+id/expandableList"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/tranceParent"
        app:layout_constraintTop_toTopOf="parent"
        android:divider="@color/tranceParent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        tools:listitem="@layout/item_parent_case"/>
Related