Search code examples
androidandroid-6.0-marshmallowandroid-popupwindow

FrameLayout$LayoutParams cannot be cast to WindowManager$LayoutParams


I am facing the similar issue explained in this link below. But the solution is not posted . Please help with the solution .

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


Solution

  • No need to use a DialogActivity. Just add one more getParent() to access the container.

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