Top-most and Bottom-most Horizontal Divider does not show up in ListView

Add a dummy footer and header

listViewContato = (ListView) view.findViewById(R.id.listview_contatos);
listViewContato.addHeaderView(new View(getActivity()));
listViewContato.addFooterView(new View(getActivity()));

Have you looked into setting android:headerDividersEnabled and android:footerDividersEnabled on the ListView?

Also, if you look for drawDivider in platform/frameworks/base/+/master/core/java/android/widger/ListView.java in the Android open source repository, you'll be able to find some more clues.


Here's how I implemented it... Bottom divider shows up after setting android:paddingBottom for the ListView. BUT in my case after setting android:paddingTop top and bottom dividers are not showing. I don't know why. So I added in my list_item_layout.xml the following code:

<View
    android:layout_width="match_parent"
    android:layout_height="1dip"
    android:background="?android:attr/listDivider" />

and in my adapter I just changing the visibility of this view:

View topDivider = v.findViewById(R.id.divider);

if (position == 0) {
    topDivider.setVisibility(View.VISIBLE);
} else {
    topDivider.setVisibility(View.GONE);
}

Hope this will helpfull to someone.