java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.view.WindowManager$LayoutParams
at android.widget.PopupWindow$1.onScrollChanged(PopupWindow.java:179)
at android.view.ViewTreeObserver.dispatchOnScrollChanged(ViewTreeObserver.java:1016)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:2897)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2824)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2436)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1321)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6708)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:894)
at android.view.Choreographer.doCallbacks(Choreographer.java:696)
at android.view.Choreographer.doFrame(Choreographer.java:631)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:880)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5765)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
而引发错误的代码如下 在PopupWindow 源码里
private final OnScrollChangedListener mOnScrollChangedListener = new OnScrollChangedListener() {
@Override
public void onScrollChanged() {
final View anchor = mAnchor != null ? mAnchor.get() : null;
if (anchor != null && mDecorView != null) {
final WindowManager.LayoutParams p = (WindowManager.LayoutParams)
mDecorView.getLayoutParams();
updateAboveAnchor(findDropDownPosition(anchor, p, mAnchorXoff, mAnchorYoff,
p.width, p.height, mAnchoredGravity));
update(p.x, p.y, -1, -1, true);
}
}
};
具体原因不明,待测试