FrameLayout $ LayoutParams无法强制转换为WindowManager $ LayoutParams

时间:2016-04-06 10:47:54

标签: android android-6.0-marshmallow android-popupwindow

我正面临下面这个链接中解释的类似问题。但该解决方案尚未发布。请帮助解决。

Android M ClassCastException: FrameLayout$LayoutParams cannot be cast to WindowManager$LayoutParams

1 个答案:

答案 0 :(得分:3)

无需使用DialogActivity。只需添加一个getParent()即可访问容器。

 if (android.os.Build.VERSION.SDK_INT > 22) {
            container = (View) pwindow.getContentView().getParent().getParent();
        }else{
            container = (View) pwindow.getContentView().getParent();
        }