ExpandableListView - group indication is stretch to fit the text size

后端 未结 7 2201
自闭症患者
自闭症患者 2020-12-14 10:36

I have group indication with small icon, and i use groupIndicator to call the selector to draw it but I see android by default stretch that icon to fits the text size

7条回答
  •  北荒
    北荒 (楼主)
    2020-12-14 11:21

    I think that the easiest thing to do in this case is include the indicator inside your row group view (as an imageView) and change its selected state based on whether the group is expanded. You'll want to make sure that your ImageView uses a selector with selected state drawables.

    Something like this:

        @Override
        public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent)
        {
            View row;
    
            if (convertView != null)
            {
                row = convertView;
            }
            else
            {
                row = LayoutInflater.from(getContext()).inflate(R.layout.group_row, null));
            }
    
    
            final ImageView indicator = (ImageView)row.findViewById(R.id.indicator);
            indicator.setSelected(isExpanded);
            return row;
        }
    

提交回复
热议问题