Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ExpandableListView - How to set divider only between parent elements

Tags:

I want to put divider only between parent elements. When i set

android:divider="@drawable/divider"
android creates divider between parent elements, but creates divider between child elements too. When i add
android:childDivider="@color/transparent"
android removes the divider between child elements, but the free space between them remains. Why? I have tried to
android:dividerHeight="0dp"
but nothing happened.

At all i want to set divider between parent elements, but i do not want any divider or empty space between child elements.

any ideas how to do that??

like image 663
Plamen Nikolov Avatar asked Jul 14 '11 14:07

Plamen Nikolov


2 Answers

In order to remove dividers just from the child views and not between the parents in the expandable list:

add android:childDivider="#00000000" in the ExapandableListView attributes in XML:

<ExpandableListView     android:id="@+id/elv"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:childDivider="#00000000" /> 

Refer this page for more information

like image 162
Amala Ray Avatar answered Oct 21 '22 10:10

Amala Ray


Give Divider color and its height (dividers will be visible when groups are collapsed)

<ExpandableListView         android:id="@+id/list"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:divider="@color/color_black"         android:dividerHeight="1dp"         android:groupIndicator="@null" /> 
like image 37
Ravi Yadav Avatar answered Oct 21 '22 10:10

Ravi Yadav