4

I can't find a way to hide dividers on an ExpandableListView without hiding the child dividers too.

Here is my code.

<ExpandableListView 
            android:id="@+id/activities_list"
            android:background="@android:color/transparent"
            android:fadingEdge="none"           
            android:groupIndicator="@android:color/transparent"
            android:divider="@android:color/transparent"
            android:childDivider="@drawable/list_divider"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />

With this code, I get no dividers on groups but no child dividers neither. If I set android:divider to "@drawable/list_divider" I get both group and child dividers.

Thanks in advance!

Hiral Vadodaria
  • 19,158
  • 5
  • 39
  • 56
thomaus
  • 6,170
  • 8
  • 45
  • 63
  • maybe this post can help you [http://stackoverflow.com/questions/3245234/android-hide-child-dividers-in-expandablelistview][1] [1]: http://stackoverflow.com/questions/3245234/android-hide-child-dividers-in-expandablelistview – Natali Jan 16 '12 at 14:57
  • This post is to hide the child dividers, which is easy to do. But thanks anyway. – thomaus Jan 17 '12 at 10:12

5 Answers5

1
expListView.setDivider(null);
expListView.setDividerHeight(2);

this will work

Wang Tavx
  • 183
  • 1
  • 9
1

The only solution I found is to put the child divider directly into the children XML, this way:

<TextView
    android:id="@+id/name"
    android:layout_centerVertical="true"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

<ImageView android:id="@+id/divider"        
    android:layout_alignParentBottom="true"
    android:layout_width="fill_parent"
    android:layout_height="1dp"
    android:background="@drawable/list_divider" />        

which is very very ugly but works.

But still, there should be a way to do that properly.

thomaus
  • 6,170
  • 8
  • 45
  • 63
0

Adding dividerHeight parameter to your ExpandableListView in your xml layout should do the trick

Gomino
  • 12,127
  • 4
  • 40
  • 49
0

How about just add a line:

android:dividerHeight="0dp"

Actually, i face the similar problem. PD asks the divider and the childDivider are both existed and different, which bothers me much. I am looking for answers too.

songzhw
  • 272
  • 3
  • 11
0

In my opinion : -Remove divider in XML :

android:divider="@null"
android:dividerHeight="0dp"

-Draw divider in View getGroupView(..,..,..,..) :

            View divider = new View(_context);
            View dividerIDU = new View(_context);
            RelativeLayout.LayoutParams rldivider = new RelativeLayout.LayoutParams(
                    RelativeLayout.LayoutParams.MATCH_PARENT, 1);
            RelativeLayout.LayoutParams rldividerShort = new RelativeLayout.LayoutParams(
                    150, 3);

            rldividerShort.setMargins(5, -1, 0, 0);
            dividerIDU.setBackgroundColor(Color.RED);


            divider.setLayoutParams(rldivider);
            dividerIDU.setLayoutParams(rldividerShort);

            divider.setBackgroundColor(Color.rgb(200, 200, 200));

            ((RelativeLayout) convertView).addView(divider);
            ((RelativeLayout) convertView).addView(dividerIDU);

-After you can set divider following group position.

IKE
  • 1
  • 1