Kreshnik Kreshnik - 8 days ago 6
Android Question

ExpandableListView, how to set the child height?

I'm trying to set the ExpandableListView item (

ViewGroup
) height. Can it be set via xml (I don't need the divider height):

<ExpandableListView
android:id="@+id/lvExp"
android:layout_height="match_parent"
android:layout_width="match_parent"/>


or it should be used this method, by manipulating the convertView:

@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView,
ViewGroup parent) { ... }


Thanks in advance.

Answer

ListView child views can be different heights, so we don't set a one-size-fits all height in the ListView's xml. Rather you can set a specific height in each of the different convertView xml's that you are inflating.

Comments