本文介绍了安卓:在ExpandableListView隐藏子分隔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从ExpandableListView完全删除分隔。至于家长的项目这是一个setDividerHeight方法,在那里我可以传递一个零值。但是,有一个为孩子分没有类似的方法。有什么办法来隐藏它?

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?

推荐答案

如果您想从 ExpandableListView setDividerHeight 是确定双方父母和孩子的物品。儿童分频器将借鉴采用相同的高度正常分频或 setDividerHeight设置()

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 必须低于 setChildDivider setDivider 或的高度将是0

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

等待更多的答案...

Waiting for more answers...

这篇关于安卓:在ExpandableListView隐藏子分隔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-03 17:09