android:headerDividersEnabled isn't working

Maximus picture Maximus · Nov 5, 2012 · Viewed 10.1k times · Source

I want to have a divider at the top of a ListView (which is placed in RelativeLayout), but when I try to use this, I get only the bottom divider:

<ListView
        android:id="@+id/last_contacts_picked_list"
        android:headerDividersEnabled="true"
        android:footerDividersEnabled="true"
        android:paddingTop="50dp"
        android:dividerHeight="5dp"
        android:layout_marginTop="50dp"
        android:divider="@android:drawable/divider_horizontal_textfield"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="..."
        android:layout_alignLeft="..."
        android:layout_alignRight="..."
        android:layout_below="..."
         />

I've got something like this:

http://i051.radikal.ru/1211/4f/a408db5e717f.png

Why doesn't it have the header divider too?

Answer

PravinCG picture PravinCG · Nov 5, 2012

That is not what android:headerDividersEnabled is supposed to do. It means that if you are adding a list header whether that header needs to be separated by a divider or not.

For your problem simply use a linearlayout with ImageView having the divider as source followed by ListView. Hope this helps.