Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The problem of top margin #183

Open
kyungin-park opened this issue May 29, 2015 · 0 comments
Open

The problem of top margin #183

kyungin-park opened this issue May 29, 2015 · 0 comments

Comments

@kyungin-park
Copy link

I had a problem of "top margin".
The margin of column[0] was lower than column[1] for the first time.

I finally found what is the cause of the problem and I am sharing with you guys to prevent having the same problem.

On StaggeredGridView.java file,

//////////// I added two functions below.
private boolean getPositionIsHeaderFooter(final int position) {

    GridItemRecord rec = mPositionData.get(position, null);
    return rec != null ? rec.isHeaderFooter : false;
}

private void removePositionColumn(final int position) {
    GridItemRecord rec = mPositionData.get(position, null);
    if (rec != null) {
        mPositionData.remove(position);
    }
}

And then see if data is not matched to HeaderOrFooter.

@Override
protected void onChildCreated(final int position, final boolean flowDown) {
    super.onChildCreated(position, flowDown);
    if (!isHeaderOrFooter(position)) {

       ///////////// I added a if statement below.
   // remove data which is unmatched to HeaderFooter or General one.
        if(getPositionIsHeaderFooter(position)) {
            removePositionColumn(position);
        }


        // do we already have a column for this position?
        final int column = getChildColumn(position, flowDown);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant