Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically adjust the height of group headers in an ExpandableListView

I have an ExpandableListView (ELV) with the groups having LinearLayout. I have set the height of the group to some value (38dip in this case, equivalent to two lines of text). If the group heading is long and would take more than 2 lines, it is not shown properly in the ELV item - some part of the view gets scrolled. On the other hand, if I change android:layout_height to "wrap_content" in the LinearLayout, the groups always show all the lines. But the line widths are variable, i.e., short titles show up with only 1 line and long titles show up with 2, 3 or 4 lines. That looks ugly. I would like to implement the height to be something like max("38dip", "wrap_content"). Is there a way to do this?

Even programmatically, I do not seem to be getting the actual height of the group if I set android:layout_height to "wrap_content". Any suggestions there?

like image 368
Samik R Avatar asked Oct 07 '10 00:10

Samik R


1 Answers

Could not solve the problem directly. Added the following to the xml layout file of the group:

   android:paddingTop="7dip"
   android:paddingBottom="7dip"

That makes the layout looking much less congested which is what I wanted to do in the first place. Moving on - but would be interested if someone else have a better solution.

like image 91
Samik R Avatar answered Sep 27 '22 18:09

Samik R