Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Appcompat "java.lang.IllegalArgumentException: parameter must be a descendant of this view" in ViewGroup.offsetRectBetweenParentAndChild

I'm experiencing this problem randomly in the last month:

java.lang.IllegalArgumentException: parameter must be a descendant of this view    at android.view.ViewGroup.offsetRectBetweenParentAndChild(ViewGroup.java:4479)    at android.view.ViewGroup.offsetDescendantRectToMyCoords(ViewGroup.java:4416)    at android.view.ViewRootImpl.scrollToRectOrFocus(ViewRootImpl.java:2656)    at android.view.ViewRootImpl.draw(ViewRootImpl.java:2300)    at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2249)    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1882)    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1009)    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5508)    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)    at android.view.Choreographer.doCallbacks(Choreographer.java:562)    at android.view.Choreographer.doFrame(Choreographer.java:532)    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)    at android.os.Handler.handleCallback(Handler.java:730)    at android.os.Handler.dispatchMessage(Handler.java:92)    at android.os.Looper.loop(Looper.java:213)    at android.app.ActivityThread.main(ActivityThread.java:5225)    at java.lang.reflect.Method.invokeNative(Method.java)    at java.lang.reflect.Method.invoke(Method.java:525)    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:741)    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)    at dalvik.system.NativeStart.main(NativeStart.java) 

After a lot of digging and tests, I figured out that the problem was introduced on October 27th after updating the Appcompat lib (android-support-v7-appcompat). Latest version of Appcompat doesn't seem to solve this issue.

I suppose that the problem is not related to similar bugs (like this question) because I've isolated the commit which introduced the problem on my repo and it is the one containing the Appcompat's update.

Any clue on this? Anyone with the same problem out there?

like image 935
bonnyz Avatar asked Dec 18 '14 09:12

bonnyz


2 Answers

You should try the following in XML:

android:descendantFocusability="beforeDescendants" 
like image 139
gauravp Avatar answered Oct 02 '22 23:10

gauravp


usually on ListView there is method named offsetRectBetweenParentAndChild() that has the job of recycling views on scroll and this method usually throws this exception.

the best answer to this question is

Append a ScrollListener to your Activity, when listView start scrolling, clear current focus.

which I found in this question.

please check it out and let me know if there is other issues.

like image 42
Pouya Danesh Avatar answered Oct 02 '22 23:10

Pouya Danesh