Android: Hide child dividers in ExpandableListView

前端 未结 6 1006
轻奢々
轻奢々 2020-12-24 11:25

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 meth

6条回答
  •  囚心锁ツ
    2020-12-24 11:36

    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...

提交回复
热议问题