I have expandablelistview and I want to add padding (or margin) between the groups items, I used margin-botton
on the group items, it works but now it is also a
Because you are using adapter
that is extending from BaseExpandableListAdapter
so you can set padding programmatically by setting padding to group item when the group is not expanding and then remove the padding when the group is expanding and for each group set padding to last child in it.
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
if (childPosition == groups.get(groupPosition).getChilds().size() - 1) {
convertView.setPadding(0, 0, 0, 20);
} else
convertView.setPadding(0, 0, 0, 0);
return convertView;
}
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
if (isExpanded)
convertView.setPadding(0, 0, 0, 0);
else
convertView.setPadding(0, 0, 0, 20);
return convertView;
}
I assume that you are using arraylist for your groups and your childs, you can just replace the groups.get(groupPosition).getChilds().size() - 1
by the size of your group depending in your structure