How to remove specific space between parent and child in an ExpandableListView

后端 未结 10 2177
太阳男子
太阳男子 2021-02-20 09:10

Can you help me identify why there is a space between the group and the child? In my case I want spaces between all groups and the child should be right below the group with no

10条回答
  •  天涯浪人
    2021-02-20 09:47

    Modify the view's padding in the method public View getChildView() using the setPadding() method of the view.

    Example:

    @Override
    public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
                                 View convertView, ViewGroup parentView){
     final Departure departure = departures.get(groupPosition);
    
     if(isLastChild)
      expListView.setDividerHeight(DIVIDER_HEIGHT);
    
     // Inflate childrow.xml file for child rows
     convertView = inflater.inflate(R.layout.view_departure_details, parentView, false);
    
     //Data handling...
    
     convertView.setPadding(0, 0, 0, 0);
    
     return convertView;
    }
    

    In the same way, if you want modify padding of the group, you will have to modify the padding in the getGroupView() method.

提交回复
热议问题