Android: Hide child dividers in ExpandableListView

Alexander Oleynikov picture Alexander Oleynikov · Jul 14, 2010 · Viewed 36.8k times · Source

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?

Answer

user393472 picture user393472 · Jul 16, 2010

If you want to completely remove dividers from ExpandableListView, setDividerHeight is ok for both parent and child items. Child divider will be draw using the same height as the normal divider or set by setDividerHeight().

And I am using one work around for us to hide one and unhide the other one, just set the divider and items in the same color like below:

 ExpandableListView expView = getExpandableListView();
 expView.setGroupIndicator(null);
 expView.setChildIndicator(null);
 expView.setChildDivider(getResources().getDrawable(R.color.greywhite));        
 expView.setDivider(getResources().getDrawable(R.color.white));
 expView.setDividerHeight(2);

setDividerHeight must below setChildDivider and setDivider, or the height will be 0.

Waiting for more answers...