emilsjolander/StickyListHeaders — pull request #59 by maraujop (2013-01-19 13:02:32+00:00)
Title: Taking header margins into account

Hi there,

First, a big thanks for this great library, it's exactly what I was looking for.

If I'm not mistaken, header margins are not considered. When I started using it, I set my header XML to this:

```xml

```

Basically a black rectangle with text. But I wanted it to be separated from the rest of the `ListView` elements, so I put some margins, because padding didn't do the trick. Then I noticed that I could see the elements scrolling behind my header, in the little gap left on top of it and when scrolling up there was a jump when changing header.

I'm new to Android, but I wanted to fix this myself, so maybe the patch is not the best thing ever, but please orientate me on how to rebase it so that it passes quality standards and can be merged. I would really like to see my first Android patch merged upstream :)

There are several easy improvements I haven't done, because I wasn't sure if the patch would make it in:
* For example the way I'm calculating header margins is mistaken and maybe makes more sense that header margins are provided as an argument. Also I'm not sure if other layouts can be cast to `LinearLayout.LayoutParameters`.
* If no margins are present, some of the calculations that are done now could be skipped or simplified, that is quite an easy fix.
* Maybe the way I'm avoiding reusing first header or trimming its top margin isn't also great code either.

So please, let me know what you think and what your feedback is.

Thanks, cheers
Miguel