Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I stumbled upon the same problem, but in a slightly different situation than yours. My <code>ListView</code> has a header (a search box), but the first item below it contains a section header (a date, or a letter) rather than being a regular list item (with the actual content in form of an image, some text, and so on). As such, I want it not to be selectable, so in my custom adapter I have overridden <code>areAllItemsEnabled</code> to return <code>false</code>.</p> <p>Big mistake, because that's exactly the culprit. See, it appears that, by design, the <code>ListView</code> implementation <a href="https://groups.google.com/forum/?fromgroups=#!topic/android-developers/uoiJo0djRZ8" rel="noreferrer">only draw dividers between two enabled items</a>, but still reserve space for dividers between an enabled item and a disabled one even if those dividers will not be drawn. The fact this is a conscious design decision does not mean it's not stupid, of course. Most weird of all, this dividers drawing policy is based just on the value returned by <code>areAllItemsEnabled</code> instead of the values returned by single calls to <code>isEnabled</code> for subsequent items.</p> <p>Thus, to work around it, I just had to return <code>true</code> from <code>areAllItemsEnabled</code> (I kept the overridden method and add a comment about this issue, otherwise I would not be able to remember it a month from now): lo and behold, white space disappeared, replaced by a divider. Now, if I want to show the <code>ListView</code> header and the first section header as being exactly adjacent, I just have to choose a divider color that's the same as the section header color.</p> <p>Really hope that's the same case as yours, or that my solution helps you in some other way.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload