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

SGV.onMeasure() does not recalculate mColumnTops/Bottoms/Lefts when SGV dimension changes #89

Open
vicianm opened this issue Sep 5, 2014 · 2 comments

Comments

@vicianm
Copy link

vicianm commented Sep 5, 2014

How to reproduce the problem:

Place SGV e.g. inside LinearLayout together with button B.

When button B is clicked change visibility of B to GONE. This way the SGV dimension is increased but SGV children are not layed out properly.

Quick (dirty) fix: recalculate mColumnTops/Bottoms/Lefts each time SGV.onMeasure() is called:

@Override
protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    if (mColumnCount <= 0) {
        boolean isLandscape = getMeasuredWidth() > getMeasuredHeight();
        mColumnCount = isLandscape ? mColumnCountLandscape : mColumnCountPortrait;
    }

    // our column width is the width of the listview
    // minus it's padding
    // minus the total items margin
    // divided by the number of columns
    mColumnWidth = calculateColumnWidth(getMeasuredWidth());

    //if (mColumnTops == null || mColumnTops.length != mColumnCount) {
        mColumnTops = new int[mColumnCount];
        initColumnTops();
    //}
    //if (mColumnBottoms == null || mColumnBottoms.length != mColumnCount) {
        mColumnBottoms = new int[mColumnCount];
        initColumnBottoms();
    //}
    //if (mColumnLefts == null || mColumnLefts.length != mColumnCount) {
        mColumnLefts = new int[mColumnCount];
        initColumnLefts();
    //}
}
@hugogz
Copy link

hugogz commented Oct 14, 2014

Please could you explain with a bit more detail this fix? I'm really interested in it but i have no idea where are some functions like initColumnTops() or calculateColumnWidth in the original SGV. Could you post the whole code please??

@JGeraldoLima
Copy link

just comment these lines didn't work for me :/ The problem occurs only if pull down the list when it is already on the last child. So all the itens disapears or gets messy

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

3 participants