Can you help me identify why there is a space between the group and the child? In my case I want spaces between all groups and the child should be right below the group with no
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"
android:dividerHeight="0dp"
/>
Refer http://qtcstation.com/2011/03/working-with-the-expandablelistview-part-1/
Use negative margin for child view in view_departure_details.Something like this:
<TextView
android:id="text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="-10dp"
android:text="@string/my_best_text"
android:background="#FF0000"
/>
I know some people consider it a bad practice to use negative margin but right it seems to be the easiest way.
Other way(the time-consuming way) is to implement you own expandable listview so that you have more control on how things are drawn.
Remove all the margins and divider height, and instead add a blank space on top of groupview itself. It should do the trick.
this is tested and is proven to work, i wanted to come back to this even months later because none of the other methods gave me results quite how i wanted them. these are displayed exactly how OP (and myself) wanted
this is my groups or categories or whatever. basically the first linear layout is just a wrapper for a view which acts as a spacer between the categories, and then another linear layout that handles all my formatting
in the ExpandableListView(not shown) i have the divider height set to 0. the spacing is instead handled by the views
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:layout_width="fill_parent"
android:layout_height="6dp"
android:background="@android:color/transparent"/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp"
android:background="#50601CBA">
<TextView
android:id="@+id/lblListHeader"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="17dp"
android:textColor="#FFFFFF" />
</LinearLayout>
</LinearLayout>
then in the child i have this.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="55dip"
android:orientation="vertical" >
<TextView
android:id="@+id/lblListItem"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="12sp"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:textColor="#FFFFFF"
android:background="#50601CBA"
/>
</LinearLayout>