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

requestLayout() "improperly called" on Lollipop #93

Open
elroid opened this issue Nov 26, 2014 · 10 comments
Open

requestLayout() "improperly called" on Lollipop #93

elroid opened this issue Nov 26, 2014 · 10 comments

Comments

@elroid
Copy link

elroid commented Nov 26, 2014

Hello, I have no problems with this library on a Samsung Galaxy Note 3 or Sony Xperia Z (KitKat), or Galaxy Nexus (JellyBean), but whenever i run it on a Nexus 5 with Lollipop, the scrolling does not function and i get the following repeating continuously for as long as the activity is open.

W/View﹕ requestLayout() improperly called by it.sephiroth.android.library.widget.HListView{227055a5 VFED..C. .F....ID 0,18-1020,258 #7f08015d app:id/galleryListView} during layout: running second layout pass
W/View﹕ requestLayout() improperly called by it.sephiroth.android.library.widget.HListView{227055a5 VFED..C. .F...... 0,18-1020,258 #7f08015d app:id/galleryListView} during second layout pass: posting in next frame

I am using the HListView as a header on a ListView. Note, i have found that if i scroll the list down a bit and come back, it seems to fix itself - no more errors and the scrolling works as expected, which is the only thing that keeps this from being a showstopper.

Any idea what could be causing this error?

@ticofab
Copy link

ticofab commented Feb 25, 2015

I am getting the same issue. Was it solved somehow?

@elroid
Copy link
Author

elroid commented Feb 25, 2015

No, i'm afraid i never received any response! I attempted to fork it and fix it myself but ran out of time simply trying to diagnose the issue...

@abhishekBansal
Copy link

facing same issue on MotoG 2 Lolipop working fine with 4.4.4 Kitkat (Moto E)

@DennisBranchOut
Copy link

Try this: http://stackoverflow.com/questions/24598977/android-requestlayout-improperly-called/26262615#26262615

Although it didn't work for me. This is a custom list view I am using, though.

@skauss
Copy link

skauss commented Aug 11, 2015

Hi,
I have exact the same problem.
Only difference is : Android 4.4.4 is OK
But on Android 5.1.1 I get the
W/View(10304): requestLayout() improperly called by it.sephiroth.android.library.widget.HListView

Error an the scroll view in in one endless loop until I press the back button.

Any idea to get a work around ?

Regards
Stephan

@skauss
Copy link

skauss commented Aug 26, 2015

Hi,
I changed in class HListView.java the method

protected void onFocusChanged( boolean gainFocus, int direction, Rect previouslyFocusedRect) 

around line 3544
At the end of this method requestLayout(); is called.

Old Code ::

        if ( closetChildIndex >= 0 ) {
            setSelectionFromLeft( closetChildIndex + mFirstPosition, closestChildLeft );
        }
        else {
            if ( LOG_ENABLED ) {
                Log.d( LOG_TAG, "requestLayout : onFocusChanged " );
            }

            requestLayout();
        }

New Code ::

            if ( gainFocus && previouslyFocusedRect != null ) {
                if ( LOG_ENABLED ) {
                    Log.d( LOG_TAG, "requestLayout : onFocusChanged " );
                }

                requestLayout();
            }
            else {
                if ( LOG_ENABLED ) {
                    Log.d( LOG_TAG, "SKIP : requestLayout : onFocusChanged " );
                }
            }

This break the repeating loop "08-24 14:26:32.466: W/View(4327): requestLayout() improperly called by ".
I have no idea if I break anything else but it works for me so fare.
I am interested if this helps any where else or if I do a big mistake

Regards
Stephan

@aichengrui00
Copy link

hao quest?

@rockerhieu
Copy link

You should wrap the calling to requestLayout() with this:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
  if (!isInLayout()) {
    requestLayout();
  }
}

@sheharyarn
Copy link

My code is completely unrelated to this project, but @rockerhieu solution still worked for me. Thanks.

@rigortek
Copy link

When I enable TextView marquee, I met the same issue, and rockerhieu's code solved my issue.

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

9 participants