Search code examples
androidlistviewdrawabledivider

How can I get the drawable of the listview Divider to reuse it?


I have a little tweak in my application: my Listview is placed between 2 LinearLayout that looks like my ListView rows.

That's a little trick that allows me to always display first and last item

and my layout looks like

[LinearLayout]

[ListView]

[LinearLayout]

I am pretty happy with the result except for one thing: I would like to insert the listview divider between those LinearLayouts and the ListView.

How should I get a drawable (or better, a xml layout) that would looks exactly like the divider?


Solution

  • You can use ListView.getDivider() to get the drawable used by a list view according to Android SDK version and theme.