Top and bottom horizontal separator not showing in ListView

I am using ListView. But the upper and lower horizontal bars are not displayed. Any idea why? I use this:

android:divider="@android:drawable/divider_horizontal_bright" 
+7
android android widget
source share
4 answers

Have you studied the android:headerDividersEnabled and android:footerDividersEnabled on a ListView ?

Also, if you are looking for drawDivider in platform / framework / base / + / master / core / java / android / widger / ListView.java in the Android open source repository , you can find some more tips.

+9
source share

Add dummy footer and header

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

Here's how I implemented it ... The bottom divider appears after installing android:paddingBottom for the ListView . BUT in my case, after installing android:paddingTop upper and lower delimiters are not displayed. I do not know why. So I added the following code to my list_item_layout.xml :

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

and in my adapter, I just change 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 helps someone.

+10
source share

I had the same problem with LibSlideMenu .

As android:headerDividersEnabled set to true, the header separator is not displayed in the sliding menu, I solved it by changing slidemenu.xml (not slidemenu_listitem.xml ) to

 <LinearLayout ...> <LinearLayout ...> <ImageView ...> (this is the header image on top of the menu) <View android:layout_width="250dip" android:layout_height="2dip" android:background="@drawable/divider" /> <ListView ...> (this is the ListView for the MenuItems) </LinearLayout> <FrameLayout ...> </FrameLayout ...> </LinearLayout> 

This will add a separator manually.

+2
source share

All Articles