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

Fatal Exception: java.lang.IllegalArgumentException parameter must be a descendant of this view #103

Open
theoyuncu8 opened this issue Nov 28, 2023 · 3 comments

Comments

@theoyuncu8
Copy link

theoyuncu8 commented Nov 28, 2023

Hello, there is an error here but I couldn't figure out how... I made some changes to the code but I still couldn't figure it out.
@yarolegovich @jonathan-caryl @antonKozyriatskyi

@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    if (getChildCount() == 0) {
        addView(rootView);
    }
    for (int i = 0; i < getChildCount(); i++) {
        View child = getChildAt(i);
        if (child == rootView) {
            int rootLeft = positionHelper.getRootLeft(dragProgress, maxDragDistance);
            child.layout(rootLeft, top, rootLeft + (right - left), bottom);   // 101. line
        } else {
            child.layout(left, top, right, bottom);
        }
    }
}

/////

android.view.ViewGroup.offsetRectBetweenParentAndChild (ViewGroup.java:6351)
android.view.ViewGroup.offsetDescendantRectToMyCoords (ViewGroup.java:6280)
androidx.core.widget.NestedScrollView.isWithinDeltaOfScreen (NestedScrollView.java:1580)
androidx.core.widget.NestedScrollView.onSizeChanged (NestedScrollView.java:2135)
android.view.View.sizeChange (View.java:23223)
android.view.View.setFrame (View.java:23173)
android.view.View.layout (View.java:23030)
android.view.ViewGroup.layout (ViewGroup.java:6468)
android.widget.FrameLayout.layoutChildren (FrameLayout.java:332)
android.widget.FrameLayout.onLayout (FrameLayout.java:270)
android.view.View.layout (View.java:23033)
android.view.ViewGroup.layout (ViewGroup.java:6468)
com.google.android.material.appbar.HeaderScrollingViewBehavior.layoutChild (HeaderScrollingViewBehavior.java:149)
com.google.android.material.appbar.ViewOffsetBehavior.onLayoutChild (ViewOffsetBehavior.java:43)
androidx.coordinatorlayout.widget.CoordinatorLayout.onLayout (CoordinatorLayout.java:918)
android.view.View.layout (View.java:23033)
android.view.ViewGroup.layout (ViewGroup.java:6468)
android.widget.RelativeLayout.onLayout (RelativeLayout.java:1103)
android.view.View.layout (View.java:23033)
android.view.ViewGroup.layout (ViewGroup.java:6468)
android.widget.FrameLayout.layoutChildren (FrameLayout.java:332)
android.widget.FrameLayout.onLayout (FrameLayout.java:270)
android.view.View.layout (View.java:23033)
android.view.ViewGroup.layout (ViewGroup.java:6468)
android.widget.FrameLayout.layoutChildren (FrameLayout.java:332)
android.widget.FrameLayout.onLayout (FrameLayout.java:270)
android.view.View.layout (View.java:23033)
android.view.ViewGroup.layout (ViewGroup.java:6468)
androidx.constraintlayout.widget.ConstraintLayout.onLayout (ConstraintLayout.java:1873)
android.view.View.layout (View.java:23033)
android.view.ViewGroup.layout (ViewGroup.java:6468)
com.example.slidingrootnav.SlidingRootNavLayout.onLayout (SlidingRootNavLayout.java:101)
android.view.View.layout (View.java:23033)
android.view.ViewGroup.layout (ViewGroup.java:6468)
android.widget.FrameLayout.layoutChildren (FrameLayout.java:332)
android.widget.FrameLayout.onLayout (FrameLayout.java:270)
android.view.View.layout (View.java:23033)
android.view.ViewGroup.layout (ViewGroup.java:6468)
android.widget.LinearLayout.setChildFrame (LinearLayout.java:1829)
android.widget.LinearLayout.layoutVertical (LinearLayout.java:1673)
android.widget.LinearLayout.onLayout (LinearLayout.java:1582)
android.view.View.layout (View.java:23033)
android.view.ViewGroup.layout (ViewGroup.java:6468)
android.widget.FrameLayout.layoutChildren (FrameLayout.java:332)
android.widget.FrameLayout.onLayout (FrameLayout.java:270)
android.view.View.layout (View.java:23033)
android.view.ViewGroup.layout (ViewGroup.java:6468)
android.widget.LinearLayout.setChildFrame (LinearLayout.java:1829)
android.widget.LinearLayout.layoutVertical (LinearLayout.java:1673)
android.widget.LinearLayout.onLayout (LinearLayout.java:1582)
android.view.View.layout (View.java:23033)
android.view.ViewGroup.layout (ViewGroup.java:6468)
android.widget.FrameLayout.layoutChildren (FrameLayout.java:332)
android.widget.FrameLayout.onLayout (FrameLayout.java:270)
com.android.internal.policy.DecorView.onLayout (DecorView.java:804)
android.view.View.layout (View.java:23033)
android.view.ViewGroup.layout (ViewGroup.java:6468)
android.view.ViewRootImpl.performLayout (ViewRootImpl.java:3601)
android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:3069)
android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:2070)
android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:8402)
android.view.Choreographer$CallbackRecord.run (Choreographer.java:1058)
android.view.Choreographer.doCallbacks (Choreographer.java:880)
android.view.Choreographer.doFrame (Choreographer.java:813)
android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:1043)
android.os.Handler.handleCallback (Handler.java:938)
android.os.Handler.dispatchMessage (Handler.java:99)
android.os.Looper.loop (Looper.java:236)
android.app.ActivityThread.main (ActivityThread.java:8037)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:656)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:967)

@theoyuncu8
Copy link
Author

theoyuncu8 commented Nov 28, 2023

android.view.ViewGroup.offsetRectBetweenParentAndChild (ViewGroup.java:6351)
android.view.ViewGroup.offsetDescendantRectToMyCoords (ViewGroup.java:6280)
androidx.core.widget.NestedScrollView.isWithinDeltaOfScreen (NestedScrollView.java:1580)
androidx.core.widget.NestedScrollView.onSizeChanged (NestedScrollView.java:2135)
android.view.View.sizeChange (View.java:23223)
android.view.View.setFrame (View.java:23173)
android.view.View.layout (View.java:23030)
android.view.ViewGroup.layout (ViewGroup.java:6468)
android.widget.FrameLayout.layoutChildren (FrameLayout.java:332)
android.widget.FrameLayout.onLayout (FrameLayout.java:270)
android.view.View.layout (View.java:23033)
android.view.ViewGroup.layout (ViewGroup.java:6468)
com.google.android.material.appbar.HeaderScrollingViewBehavior.layoutChild (HeaderScrollingViewBehavior.java:149)
com.google.android.material.appbar.ViewOffsetBehavior.onLayoutChild (ViewOffsetBehavior.java:43)
androidx.coordinatorlayout.widget.CoordinatorLayout.onLayout (CoordinatorLayout.java:918)
android.view.View.layout (View.java:23033)
android.view.ViewGroup.layout (ViewGroup.java:6468)
android.widget.RelativeLayout.onLayout (RelativeLayout.java:1103)
android.view.View.layout (View.java:23033)
android.view.ViewGroup.layout (ViewGroup.java:6468)
android.widget.FrameLayout.layoutChildren (FrameLayout.java:332)
android.widget.FrameLayout.onLayout (FrameLayout.java:270)
android.view.View.layout (View.java:23033)
android.view.ViewGroup.layout (ViewGroup.java:6468)
android.widget.FrameLayout.layoutChildren (FrameLayout.java:332)
android.widget.FrameLayout.onLayout (FrameLayout.java:270)
android.view.View.layout (View.java:23033)
android.view.ViewGroup.layout (ViewGroup.java:6468)
androidx.constraintlayout.widget.ConstraintLayout.onLayout (ConstraintLayout.java:1873)
android.view.View.layout (View.java:23033)
android.view.ViewGroup.layout (ViewGroup.java:6468)
com.example.slidingrootnav.SlidingRootNavLayout.onLayout (SlidingRootNavLayout.java:101) // Hi there!!!!
android.view.View.layout (View.java:23033)
android.view.ViewGroup.layout (ViewGroup.java:6468)
android.widget.FrameLayout.layoutChildren (FrameLayout.java:332)
android.widget.FrameLayout.onLayout (FrameLayout.java:270)
android.view.View.layout (View.java:23033)
android.view.ViewGroup.layout (ViewGroup.java:6468)
android.widget.LinearLayout.setChildFrame (LinearLayout.java:1829)
android.widget.LinearLayout.layoutVertical (LinearLayout.java:1673)
android.widget.LinearLayout.onLayout (LinearLayout.java:1582)
android.view.View.layout (View.java:23033)
android.view.ViewGroup.layout (ViewGroup.java:6468)
android.widget.FrameLayout.layoutChildren (FrameLayout.java:332)
android.widget.FrameLayout.onLayout (FrameLayout.java:270)
android.view.View.layout (View.java:23033)
android.view.ViewGroup.layout (ViewGroup.java:6468)
android.widget.LinearLayout.setChildFrame (LinearLayout.java:1829)
android.widget.LinearLayout.layoutVertical (LinearLayout.java:1673)
android.widget.LinearLayout.onLayout (LinearLayout.java:1582)
android.view.View.layout (View.java:23033)
android.view.ViewGroup.layout (ViewGroup.java:6468)
android.widget.FrameLayout.layoutChildren (FrameLayout.java:332)
android.widget.FrameLayout.onLayout (FrameLayout.java:270)
com.android.internal.policy.DecorView.onLayout (DecorView.java:804)
android.view.View.layout (View.java:23033)
android.view.ViewGroup.layout (ViewGroup.java:6468)
android.view.ViewRootImpl.performLayout (ViewRootImpl.java:3601)
android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:3069)
android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:2070)
android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:8402)
android.view.Choreographer$CallbackRecord.run (Choreographer.java:1058)
android.view.Choreographer.doCallbacks (Choreographer.java:880)
android.view.Choreographer.doFrame (Choreographer.java:813)
android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:1043)
android.os.Handler.handleCallback (Handler.java:938)
android.os.Handler.dispatchMessage (Handler.java:99)
android.os.Looper.loop (Looper.java:236)
android.app.ActivityThread.main (ActivityThread.java:8037)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:656)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:967)

@theoyuncu8
Copy link
Author

theoyuncu8 commented Nov 28, 2023

@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    if (getChildCount() == 0) {
        addView(rootView);
    }
    for (int i = 0; i < getChildCount(); i++) {
        View child = getChildAt(i);
        if (child == rootView) {
            int rootLeft = positionHelper.getRootLeft(dragProgress, maxDragDistance);
            child.layout(rootLeft, top, rootLeft + (right - left), bottom);   // 101. line
        } else {
            child.layout(left, top, right, bottom);
        }
    }
}

@theoyuncu8
Copy link
Author

@yarolegovich Please help me!

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