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

When the device is rotated, listview was overlapped. #184

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

When the device is rotated, listview was overlapped. #184

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

Comments

@kyungin-park
Copy link

I used the column count "2" for both of portrait and landscape.
When the device is rotated, listview was overlapped.
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 mIsRotated variable below.
private boolean mIsRotated = false;

@Override
protected void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    mIsRotated = true;
}



@Override
protected void onSizeChanged(int w, int h) {
    ...............
    //////////// I checked mIsRotated variable instead of mColumnCount.
    // if (mColumnCount != newColumnCount) {
            if(mIsRotated) {
        ............
                   requestLayout();
        //////////// I added code below after layout changes.
                    mIsRotated = false;
    }
}
@yamila-fraiman
Copy link

Set column_count attribute for the two orientations instead of setting it once:
E.g.:
staggered:column_count_landscape="4"
staggered:column_count_portrait="2"

@kyungin-park
Copy link
Author

I needed to set 2 for both of them(portrait, landscape). That's the reason why I modified the code...

@mrdjohnson
Copy link

@kyungin-park it sounds like you found a fix for the the overlapping rotation issue. I attempted a CustomStaggeredGridView with your changes, but it does not seem to work, was the code you posted complete or was there more to it, are there further instructions?

@kyungin-park
Copy link
Author

@DocJava In my case, the code I mentioned was enough to solve this problem... Hmm... The cause was that requestLayout() should be called after rotation....

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